Problem: The app crashed in certain download failures (either by pressing download button or just getting a chapter from fanfiction).
Root cause: when the network is unstable, and the underlying Jsoup in some cases will convert checked IOException to UncheckedIOException, which then bypasses all error handling in the app and causes the app crashed.
Example stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: Story Loader Thread
Process: com.spicymango.fanfictionreader, PID: 20636
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:161)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
...
Caused by: org.jsoup.UncheckedIOException: java.io.IOException: Underlying input stream returned zero bytes
at org.jsoup.parser.CharacterReader.bufferUp(CharacterReader.java:60)
at org.jsoup.parser.CharacterReader.<init>(CharacterReader.java:35)
at org.jsoup.parser.CharacterReader.<init>(CharacterReader.java:39)
at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:35)
at org.jsoup.parser.HtmlTreeBuilder.initialiseParse(HtmlTreeBuilder.java:66)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:44)
at org.jsoup.parser.Parser.parseInput(Parser.java:39)
at org.jsoup.helper.DataUtil.parseInputStream(DataUtil.java:151)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:832)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:289)
at com.spicymango.fanfictionreader.activity.reader.StoryDisplayActivity$FanFictionLoader.getStoryFromSite(StoryDisplayActivity.java:638)
at com.spicymango.fanfictionreader.activity.reader.StoryLoader.loadInBackground(StoryLoader.java:96)
at com.spicymango.fanfictionreader.activity.reader.StoryLoader.loadInBackground(StoryLoader.java:15)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:302)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:57)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:45)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:138)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.io.IOException: Underlying input stream returned zero bytes
...
App Version: 1.57b
Problem: The app crashed in certain download failures (either by pressing download button or just getting a chapter from fanfiction).
Root cause: when the network is unstable, and the underlying
Jsoup
in some cases will convert checkedIOException
toUncheckedIOException
, which then bypasses all error handling in the app and causes the app crashed.Example stacktrace: