App crashes due to NullPointerException
License and Copyright Notice
By submitting this issue or commenting on this issue, or contributing any content to this issue, you certify under the Developer Certificate of Origin that the content you post may be licensed under GPLv3 (for code) or CC-BY-SA 4.0 International (for non-code content).
Summary
App is crashing when it encounters a ShelfLife
object with a null
metric. Instead of crashing it should display any information the ShelfLife
object may contain, such as "Storage Tips".
Steps to reproduce
- Go to the "Check Expiration Date" feature and enter or scan a barcode that is not already in the database.
- For
Category
select: "Condiments, Sauces, & Canned Goods - For
Product
select: "Ketchup, cocktail, or chili sauce" - Press "Accept"
- Press "Accept"
What is the current bug behavior?
The app will crash due to a NullPointerException
.
What is the expected correct behavior?
It should navigate to DisplayTrueExpirationFragment
and display any information the ShelfLife object may contain.
Relevant logs and/or screenshots
E/AndroidRuntime: FATAL EXCEPTION: main
Process: edu.ncc.nest.nestapp, PID: 3652
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at edu.ncc.nest.nestapp.CheckExpirationDate.Fragments.DisplayTrueExpirationFragment.getShortestShelfLife(DisplayTrueExpirationFragment.java:195)
at edu.ncc.nest.nestapp.CheckExpirationDate.Fragments.DisplayTrueExpirationFragment.lambda$onViewCreated$0$DisplayTrueExpirationFragment(DisplayTrueExpirationFragment.java:106)
at edu.ncc.nest.nestapp.CheckExpirationDate.Fragments.-$$Lambda$DisplayTrueExpirationFragment$eoQf2ZW-GDO7TtxQSjpeY7UWuO4.onFragmentResult(Unknown Source:4)
at androidx.fragment.app.FragmentManager$6.onStateChanged(FragmentManager.java:896)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:265)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:307)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:148)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:134)
at androidx.fragment.app.Fragment.performStart(Fragment.java:3026)
at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:589)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:300)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2106)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Possible fixes
Remove getShortestShelfLife() method and update the app to display only the dop_pantryLife
shelf life. Add null
checks that display "N/A" if any data is null.
Weight Explanation
I gave this a weight of two since it should be a simple fix but is a bug that needs to be fixed as soon as possible since the app hard crashes.
Labels
NEST
component:check-expiration-date
type::bug
status::doing