Skip to content

Commit 3f69332

Browse files
committed
NPE fix in AsyncHttpResponseHandler for onFailure method
1 parent 643b250 commit 3f69332

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/src/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,8 @@ public void onFailure(int statusCode, Header[] headers, Throwable error, String
291291
* @param error the underlying cause of the failure
292292
*/
293293
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
294-
String response;
295294
try {
296-
response = new String(responseBody, getCharset());
295+
String response = responseBody == null ? null : new String(responseBody, getCharset());
297296
onFailure(statusCode, headers, error, response);
298297
} catch (UnsupportedEncodingException e) {
299298
Log.e(LOG_TAG, e.toString());

0 commit comments

Comments
 (0)