Expand scope of try/catch in DownloadTouchIcon
Bug: 3405675
In case something manages to sneak a bad URL through all the pre-checks,
just catch all exceptions that occur when trying to download the touch
icon and log the exception.
Change-Id: I202e89d9913cd5c3edd309fc8e4c415052d3dd7d
diff --git a/src/com/android/browser/DownloadTouchIcon.java b/src/com/android/browser/DownloadTouchIcon.java
index ad16131..64a7316 100644
--- a/src/com/android/browser/DownloadTouchIcon.java
+++ b/src/com/android/browser/DownloadTouchIcon.java
@@ -39,10 +39,10 @@
import android.webkit.WebView;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
class DownloadTouchIcon extends AsyncTask<String, Void, Void> {
+
private final ContentResolver mContentResolver;
private Cursor mCursor;
private final String mOriginalUrl;
@@ -110,18 +110,21 @@
String url = values[0];
if (inDatabase || mMessage != null) {
- AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
- HttpHost httpHost = Proxy.getPreferredHttpHost(mContext, url);
- if (httpHost != null) {
- ConnRouteParams.setDefaultProxy(client.getParams(), httpHost);
- }
-
- HttpGet request = new HttpGet(url);
-
- // Follow redirects
- HttpClientParams.setRedirecting(client.getParams(), true);
+ AndroidHttpClient client = null;
+ HttpGet request = null;
try {
+ client = AndroidHttpClient.newInstance(mUserAgent);
+ HttpHost httpHost = Proxy.getPreferredHttpHost(mContext, url);
+ if (httpHost != null) {
+ ConnRouteParams.setDefaultProxy(client.getParams(), httpHost);
+ }
+
+ request = new HttpGet(url);
+
+ // Follow redirects
+ HttpClientParams.setRedirecting(client.getParams(), true);
+
HttpResponse response = client.execute(request);
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = response.getEntity();
@@ -139,12 +142,14 @@
}
}
}
- } catch (IllegalArgumentException ex) {
- request.abort();
- } catch (IOException ex) {
- request.abort();
+ } catch (Exception ex) {
+ if (request != null) {
+ request.abort();
+ }
} finally {
- client.close();
+ if (client != null) {
+ client.close();
+ }
}
}