Fix NPE when unexpected network drop

Fix #839
This commit is contained in:
topjohnwu 2018-12-09 03:28:28 -05:00
parent 9c63e31da6
commit fd4a27dbf2

View File

@ -92,6 +92,10 @@ public class UpdateRepos {
req.addHeaders(Const.Key.IF_NONE_MATCH, etag); req.addHeaders(Const.Key.IF_NONE_MATCH, etag);
} }
ANResponse<JSONArray> res = req.build().executeForJSONArray(); ANResponse<JSONArray> res = req.build().executeForJSONArray();
// Network drop
if (res.getOkHttpResponse() == null)
return false;
// JSON not updated
if (res.getOkHttpResponse().code() == HttpURLConnection.HTTP_NOT_MODIFIED) if (res.getOkHttpResponse().code() == HttpURLConnection.HTTP_NOT_MODIFIED)
return false; return false;
// Current page is the last page // Current page is the last page