Bug 762974 - Don't retry if delegate or observer callbacks throw in BaseResource. r=liuche

This commit is contained in:
Richard Newman 2012-06-08 17:09:54 -07:00
parent 9f658c894a
commit 7291a3cb6e

View File

@ -240,16 +240,13 @@ public class BaseResource implements Resource {
}
private void execute() {
HttpResponse response;
try {
HttpResponse response = client.execute(request, context);
response = client.execute(request, context);
Logger.debug(LOG_TAG, "Response: " + response.getStatusLine().toString());
HttpResponseObserver observer = getHttpResponseObserver();
if (observer != null) {
observer.observeHttpResponse(response);
}
delegate.handleHttpResponse(response);
} catch (ClientProtocolException e) {
delegate.handleHttpProtocolException(e);
return;
} catch (IOException e) {
Logger.debug(LOG_TAG, "I/O exception returned from execute.");
if (!retryOnFailedRequest) {
@ -257,6 +254,7 @@ public class BaseResource implements Resource {
} else {
retryRequest();
}
return;
} catch (Exception e) {
// Bug 740731: Don't let an exception fall through. Wrapping isn't
// optimal, but often the exception is treated as an Exception anyway.
@ -265,7 +263,15 @@ public class BaseResource implements Resource {
} else {
retryRequest();
}
return;
}
// Don't retry if the observer or delegate throws!
HttpResponseObserver observer = getHttpResponseObserver();
if (observer != null) {
observer.observeHttpResponse(response);
}
delegate.handleHttpResponse(response);
}
private void retryRequest() {