Bug 740731 - Catch unchecked exceptions in two places in BaseResource. r=rnewman
authorNick Alexander <nalexander@mozilla.com>
Thu, 31 May 2012 12:14:32 -0700
changeset 95384 0a4417ac4889c92ca712d02f4e9f02f77df140fb
parent 95383 9265be2869cabd5b4a9ac94ae53be8e1778e424d
child 95385 5e22cc18646d49b94b7d1add0f440f98f4f2d982
push id10097
push usernalexander@mozilla.com
push dateThu, 31 May 2012 20:52:28 +0000
treeherdermozilla-inbound@5e22cc18646d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs740731
milestone15.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 740731 - Catch unchecked exceptions in two places in BaseResource. r=rnewman
mobile/android/base/sync/net/BaseResource.java
--- a/mobile/android/base/sync/net/BaseResource.java
+++ b/mobile/android/base/sync/net/BaseResource.java
@@ -4,16 +4,17 @@
 
 package org.mozilla.gecko.sync.net;
 
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 
 import javax.net.ssl.SSLContext;
 
 import org.mozilla.gecko.sync.Logger;
 
@@ -244,32 +245,43 @@ public class BaseResource implements Res
       if (observer != null) {
         observer.observeHttpResponse(response);
       }
       delegate.handleHttpResponse(response);
     } catch (ClientProtocolException e) {
       delegate.handleHttpProtocolException(e);
     } catch (IOException e) {
       delegate.handleHttpIOException(e);
+    } 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.
+      delegate.handleHttpIOException(new IOException(e));
     }
   }
 
   private void go(HttpRequestBase request) {
    if (delegate == null) {
       throw new IllegalArgumentException("No delegate provided.");
     }
     this.request = request;
     try {
       this.prepareClient();
     } catch (KeyManagementException e) {
       Logger.error(LOG_TAG, "Couldn't prepare client.", e);
       delegate.handleTransportException(e);
+      return;
     } catch (NoSuchAlgorithmException e) {
       Logger.error(LOG_TAG, "Couldn't prepare client.", e);
       delegate.handleTransportException(e);
+      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.
+      delegate.handleTransportException(new GeneralSecurityException(e));
+      return;
     }
     this.execute();
   }
 
   @Override
   public void get() {
     Logger.debug(LOG_TAG, "HTTP GET " + this.uri.toASCIIString());
     this.go(new HttpGet(this.uri));