From 299682bb6d4e2e9f2b0f0553f6f475f7f7585a99 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Sat, 5 May 2012 20:07:40 +0200 Subject: [PATCH] Fix AndroidHttpClient leaks. --- src/org/fox/ttrss/ApiRequest.java | 7 +++++-- src/org/fox/ttrss/FeedsFragment.java | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/org/fox/ttrss/ApiRequest.java b/src/org/fox/ttrss/ApiRequest.java index 837aaa0c..6526ca28 100644 --- a/src/org/fox/ttrss/ApiRequest.java +++ b/src/org/fox/ttrss/ApiRequest.java @@ -132,10 +132,12 @@ public class ApiRequest extends AsyncTask, Integer, JsonE } catch (IllegalArgumentException e) { m_lastError = ApiError.INVALID_URL; e.printStackTrace(); + client.close(); return null; } catch (Exception e) { m_lastError = ApiError.OTHER_ERROR; e.printStackTrace(); + client.close(); return null; } @@ -153,6 +155,7 @@ public class ApiRequest extends AsyncTask, Integer, JsonE } catch (MalformedURLException e) { m_lastError = ApiError.INVALID_URL; e.printStackTrace(); + client.close(); return null; } @@ -218,8 +221,6 @@ public class ApiRequest extends AsyncTask, Integer, JsonE } } - client.close(); - return null; case 401: m_lastError = ApiError.HTTP_UNAUTHORIZED; @@ -238,6 +239,7 @@ public class ApiRequest extends AsyncTask, Integer, JsonE break; } + client.close(); return null; } catch (javax.net.ssl.SSLPeerUnverifiedException e) { m_lastError = ApiError.SSL_REJECTED; @@ -253,6 +255,7 @@ public class ApiRequest extends AsyncTask, Integer, JsonE e.printStackTrace(); } + client.close(); return null; } } diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index b8ac66be..02ac2104 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -512,6 +512,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh targetUrl = new URL(fetchUrl); } catch (MalformedURLException e) { e.printStackTrace(); + client.close(); return; } @@ -543,12 +544,12 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh fos.close(); is.close(); - - client.close(); } catch (Exception e) { e.printStackTrace(); } + + client.close(); } protected void onPostExecute(Integer result) {