Incorrect dialog displayed when an error occurs during the population of the Nest.db database
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
Error dialog not shown when a BackgroundTask
that populates the database encounters an InterruptedException
or ExecutionException
. Also, the user is not blocked from continuing further into the feature when one of the two errors occur.
Steps to reproduce
- 'Wipe Data' on your device using 'AVD Manager' so the app has to recreate the
Nest.db
database. - Disconnect your device from the internet.
- Launch the app on that device.
- Click 'CHECK EXPIRATION DATE' button.
What is the current bug behavior?
After a little while you should see the 'Database successfully loaded' dialog (incorrect). This is the wrong dialog. An error will have occurred that will prevent the database from being populated, since the device is not connected to the internet.
To confirm that an error actually occurred: Check the log from the app and you should see the following error/warning
java.util.concurrent.ExecutionException: java.net.UnknownHostException: Unable to resolve host "foodkeeper-api.herokuapp.com": No address associated with hostname
What is the expected correct behavior?
The error dialog should have been displayed to the user, and it should stop the user from continuing any further.
Relevant logs and/or screenshots
Possible fixes
Line 177 in NestDBOpenHelper.java
should be updated to throw a RuntimeException
containing the caught exception as the cause. This will allow the BackgroundTask
that the code is executing on to see the caught exception.
Labels
NEST
Component:Check-Expiration-Date
Type::Bug
Status::Doing
Weight Explanation
I'm giving this a weight of 2 since it should be an easy fix but it takes a bit of understanding as to how the database is being loaded with nested BackgroundTask
.