Fix AndroidHttpClient leaks.

This commit is contained in:
Michael Kuhn 2012-05-05 20:07:40 +02:00 committed by Andrew Dolgov
parent c13dd67f43
commit 299682bb6d
2 changed files with 8 additions and 4 deletions

View File

@ -132,10 +132,12 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, 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<HashMap<String,String>, 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<HashMap<String,String>, Integer, JsonE
}
}
client.close();
return null;
case 401:
m_lastError = ApiError.HTTP_UNAUTHORIZED;
@ -238,6 +239,7 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, 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<HashMap<String,String>, Integer, JsonE
e.printStackTrace();
}
client.close();
return null;
}
}

View File

@ -512,6 +512,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
targetUrl = new URL(fetchUrl);
} catch (MalformedURLException e) {
e.printStackTrace();
client.close();
return;
}
@ -544,11 +545,11 @@ 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) {