ArrayIndexOutOfBoundsException - After scanning bottled water and inputting an expiration date || App crashes when bottled water is scanned and an expiration date is input.
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
When scanning a bottle of water, after reaching the SelectPrintedExpirationDate page, when the user inputs the bottle's on-label expiration date and hitting the 'Accept' button, the application crashes.
Steps to reproduce
IMPORTANT (it is really important that the item not already exist in the database)
Using AVG manager, clear database data.
OR
If using an Android device, simply uninstall app, and then run the app from within Android Studio.
Run the App, choose Check Expiration Date.
Scan the bottle of water.
You will be taken to SelectItemFragment:
Input Brand Name
Input Description
Select 'Beverages' as the "Category"
Select 'Water' as the "Product"
Select 'commercially bottled' as the "Type"
Hit the 'Accept' button, the app will take you to SelectPrintedExpirationDate screen.
Input the expiration date as printed on the bottle.
Hit Accept.
What is the current bug behavior?
As soon as the 'Accept' button is pressed, the app crashes completely.
What is the expected correct behavior?
The correct behavior should be that the app accepts the printed expiration date, and upon hitting 'Accept' the user should be taken to DisplayTrueExpiration screen which should then allow the user to see the true expiration date of the bottle of water.
Relevant logs and/or screenshots
The following is the error log received when this particular crash occurs.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: edu.ncc.nest.nestapp, PID: 14277
java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.get(ArrayList.java:439)
at edu.ncc.nest.nestapp.CheckExpirationDate.Fragments.DisplayTrueExpirationFragment.getShortestShelfLife(DisplayTrueExpirationFragment.java:183)
at edu.ncc.nest.nestapp.CheckExpirationDate.Fragments.DisplayTrueExpirationFragment.lambda$onViewCreated$0$DisplayTrueExpirationFragment(DisplayTrueExpirationFragment.java:100)
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:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Possible fixes
I am currently trying to trace through why this happens! Will update this page when I figure it out!
Weight
I want to justify the weight I gave to this. Water is an extremely common item, and I would be willing to bet that a lot of water is donated to the Nest. With that said, I don't think it is the highest priority, which in my eyes should be reserved for those bugs that directly impede the functioning of the app in general. In my eyes, a highly weighted issue should be one that is much more general, ie, the bug that it causes affects the ability to scan very many items. Versus, a medium weighted issue, much like this issue, the item is common enough that this would be a huge issue to the staff of the Nest, but not a huge enough issue that they couldn't continue using the app for various other products. A low weighted issue would be one that maybe doesn't affect the functionality of the app much if at all.
Labels
Labels I wanted to give to this issue:
component::check-expiration-date
type::bug
status::doing