From 48eed91c62c319068bfc3a0d84f7f11c627b99c0 Mon Sep 17 00:00:00 2001 From: Espen Riskedal Date: Thu, 22 Aug 2013 15:18:29 +0200 Subject: [PATCH] Fix crash in RetryHandler Is is possible for context.getAttribute(...) to return null, so we have to check currentReq before we call getMethod() on it. Without this fix the HttpClient seems to hang forever and onFinish() is never called in the AsyncHttpHandlers. --- src/com/loopj/android/http/RetryHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/loopj/android/http/RetryHandler.java b/src/com/loopj/android/http/RetryHandler.java index 5256aad21..7d75cd9ab 100644 --- a/src/com/loopj/android/http/RetryHandler.java +++ b/src/com/loopj/android/http/RetryHandler.java @@ -89,7 +89,7 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte if(retry) { // resend all idempotent requests HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute( ExecutionContext.HTTP_REQUEST ); - String requestType = currentReq.getMethod(); + String requestType = currentReq != null ? currentReq.getMethod() : ""; retry = !requestType.equals("POST"); } @@ -101,7 +101,7 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte return retry; } - + protected boolean isInList(HashSet> list, Throwable error) { Iterator> itr = list.iterator(); while (itr.hasNext()) {