Bug 762974 - Don't retry if delegate or observer callbacks throw in BaseResource. r=liuche
authorRichard Newman <rnewman@mozilla.com>
Fri, 08 Jun 2012 17:09:54 -0700
changeset 101019 8a73ed10f75edf68a0f1303f8615044975c9f278
parent 101018 cd7149361d0aa137d9ae9888898426cb421b8a7f
child 101020 b0d55b8d2f5d36859aa91806f87b041ea8360850
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs762974
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 762974 - Don't retry if delegate or observer callbacks throw in BaseResource. r=liuche
mobile/android/base/sync/net/BaseResource.java
--- a/mobile/android/base/sync/net/BaseResource.java
+++ b/mobile/android/base/sync/net/BaseResource.java
@@ -235,42 +235,48 @@ public class BaseResource implements Res
     if (connectionManager == null) {
       return;
     }
     Logger.debug(LOG_TAG, "Shutting down connection manager.");
     connectionManager.shutdown();
   }
 
   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) {
         delegate.handleHttpIOException(e);
       } 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.
       if (!retryOnFailedRequest) {
         delegate.handleHttpIOException(new IOException(e));
       } 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() {
     // Only retry once.
     retryOnFailedRequest = false;
     Logger.debug(LOG_TAG, "Retrying request...");
     this.execute();
   }