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 12cb93585a
commit be30cdd369

View File

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