MADWI/AppWIZUT2

Crash when Avris server doesn't respond

Closed this issue · 1 comments

When network is connected but Avris server won't respond, the application will crash

Tested on branch OfflineData, revision 37bea8b

12-13 09:39:21.010 4487-11892/pl.edu.zut.mad.appwizut2 E/bus_loader: couldn't load site content

                                                                     --------- beginning of crash
12-13 09:39:21.033 4487-11892/pl.edu.zut.mad.appwizut2 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
                                                                         Process: pl.edu.zut.mad.appwizut2, PID: 4487
                                                                         java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                             at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                             at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                             at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                             at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                             at java.lang.Thread.run(Thread.java:818)
                                                                          Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                                                                             at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
                                                                             at org.json.JSONTokener.nextValue(JSONTokener.java:94)
                                                                             at org.json.JSONObject.<init>(JSONObject.java:156)
                                                                             at org.json.JSONObject.<init>(JSONObject.java:173)
                                                                             at pl.edu.zut.mad.appwizut2.network.BusTimetableLoader$GetBusInfo.doInBackground(BusTimetableLoader.java:88)
                                                                             at pl.edu.zut.mad.appwizut2.network.BusTimetableLoader$GetBusInfo.doInBackground(BusTimetableLoader.java:71)
                                                                             at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                             at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                             at java.lang.Thread.run(Thread.java:818) 

When I was deprecating getPage, the point was not to copy it's behavior to another method returning invalid value just like getPage (getPage returned empty string, here getUrlSource returns null causing crash). If you want that old behavior, stick to deprecated getPage.

dmcyk commented

fixed on local branch, waiting for other possible issues before next commit.