Skip to content

Commit 2b91948

Browse files
committed
Invalid duplicate onFailure call
1 parent 1173989 commit 2b91948

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ static class ResponderHandler extends Handler {
104104
ResponderHandler(AsyncHttpResponseHandler service) {
105105
mResponder = new WeakReference<AsyncHttpResponseHandler>(service);
106106
}
107+
107108
@Override
108-
public void handleMessage(Message msg)
109-
{
109+
public void handleMessage(Message msg) {
110110
AsyncHttpResponseHandler service = mResponder.get();
111-
if (service != null) {
112-
service.handleMessage(msg);
113-
}
111+
if (service != null) {
112+
service.handleMessage(msg);
113+
}
114114
}
115115
}
116116

@@ -216,9 +216,9 @@ public void onSuccess(int statusCode, String content) {
216216
/**
217217
* Fired when a request returns successfully, override to handle in your own code
218218
*
219-
* @param statusCode the status code of the response
220-
* @param headers return headers, if any
221-
* @param responseBody the body of the HTTP response from the server
219+
* @param statusCode the status code of the response
220+
* @param headers return headers, if any
221+
* @param responseBody the body of the HTTP response from the server
222222
*/
223223
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
224224
try {
@@ -229,6 +229,7 @@ public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
229229
onFailure(statusCode, headers, e, (String) null);
230230
}
231231
}
232+
232233
/**
233234
* Fired when a request fails to complete, override to handle in your own code
234235
*
@@ -284,29 +285,28 @@ public void onFailure(int statusCode, Header[] headers, Throwable error, String
284285
/**
285286
* Fired when a request fails to complete, override to handle in your own code
286287
*
287-
* @param statusCode return HTTP status code
288-
* @param headers return headers, if any
289-
* @param responseBody the response body, if any
290-
* @param error the underlying cause of the failure
288+
* @param statusCode return HTTP status code
289+
* @param headers return headers, if any
290+
* @param responseBody the response body, if any
291+
* @param error the underlying cause of the failure
291292
*/
292293
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
293294
String response = null;
294295
try {
295296
response = new String(responseBody, getCharset());
297+
onFailure(statusCode, headers, error, response);
296298
} catch (UnsupportedEncodingException e) {
297299
Log.e(LOG_TAG, e.toString());
298300
onFailure(statusCode, headers, e, null);
299301
}
300-
onFailure(statusCode, headers, error, response);
301302
}
302303

303304
/**
304305
* Fired when a retry occurs, override to handle in your own code
305-
*
306306
*/
307307
public void onRetry() {
308308
}
309-
309+
310310

311311
//
312312
// Pre-processing of messages (executes in background threadpool thread)
@@ -333,9 +333,9 @@ protected void sendFinishMessage() {
333333
}
334334

335335
protected void sendRetryMessage() {
336-
sendMessage(obtainMessage(RETRY_MESSAGE, null));
336+
sendMessage(obtainMessage(RETRY_MESSAGE, null));
337337
}
338-
338+
339339
// Methods which emulate android's Handler and Message methods
340340
protected void handleMessage(Message msg) {
341341
Object[] response;
@@ -361,7 +361,7 @@ protected void handleMessage(Message msg) {
361361
break;
362362
case RETRY_MESSAGE:
363363
onRetry();
364-
break;
364+
break;
365365
}
366366
}
367367

@@ -423,7 +423,7 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
423423
if (contentLength < 0) {
424424
contentLength = BUFFER_SIZE;
425425
}
426-
try{
426+
try {
427427
ByteArrayBuffer buffer = new ByteArrayBuffer((int) contentLength);
428428
try {
429429
byte[] tmp = new byte[BUFFER_SIZE];
@@ -438,7 +438,7 @@ byte[] getResponseData(HttpEntity entity) throws IOException {
438438
instream.close();
439439
}
440440
responseBody = buffer.buffer();
441-
} catch( OutOfMemoryError e ) {
441+
} catch (OutOfMemoryError e) {
442442
System.gc();
443443
throw new IOException("File too large to fit into available memory");
444444
}

0 commit comments

Comments
 (0)