etsy/EtsyAndroidSDK — pull request #4 by seanoshea (2012-11-17 17:50:12+00:00)
Title: Avoiding NPEs with Null Responses

Saw the following NPE when reading a response over a flaky connection:

E/AndroidRuntime( 3818): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 3818):	at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime( 3818):	at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
E/AndroidRuntime( 3818):	at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
E/AndroidRuntime( 3818):	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
E/AndroidRuntime( 3818):	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
E/AndroidRuntime( 3818):	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
E/AndroidRuntime( 3818):	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
E/AndroidRuntime( 3818):	at java.lang.Thread.run(Thread.java:1019)
E/AndroidRuntime( 3818): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3818):	at java.io.Reader.(Reader.java:65)
E/AndroidRuntime( 3818):	at java.io.InputStreamReader.(InputStreamReader.java:122)
E/AndroidRuntime( 3818):	at java.io.InputStreamReader.(InputStreamReader.java:59)
E/AndroidRuntime( 3818):	at com.etsy.etsyCore.EtsyResult.parseResult(EtsyResult.java:87)
E/AndroidRuntime( 3818):	at com.etsy.etsyCore.EtsyRequestManager.runRequest(EtsyRequestManager.java:185)

Difficult to repro this problem, but the code attached to this pull request could help mitigate against application crashes due to uncaught NPEs.