Skip to content

Commit

Permalink
Guard for a null server response. (#10175)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypbnv authored and hansemannn committed Jul 20, 2018
1 parent 15c915f commit 38a720d
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,24 @@ private void handleResponse(HttpURLConnection connection) throws IOException
responseData = null;

int status = connection.getResponseCode();
// Stream holding the server's response
InputStream in;

// Stream holding the buffered response if there is one
InputStream is = null;
if (status >= 400) {
in = connection.getErrorStream();
} else {
in = connection.getInputStream();
}

if ("gzip".equalsIgnoreCase(contentEncoding)) {
in = new GZIPInputStream(in);
// Guard for null stream response from the server
if (in != null) {
if ("gzip".equalsIgnoreCase(contentEncoding)) {
in = new GZIPInputStream(in);
}
is = new BufferedInputStream(in);
}

InputStream is = new BufferedInputStream(in);

if (is != null) {
Log.d(TAG, "Content length: " + contentLength, Log.DEBUG_MODE);
int count = 0;
Expand Down

0 comments on commit 38a720d

Please sign in to comment.