Fixed two leaks when using AndroidHttpClient.

git-svn-id: https://zxing.googlecode.com/svn/trunk@675 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2008-11-06 19:55:38 +00:00
parent 56644b1af2
commit de83fdf806
2 changed files with 7 additions and 1 deletions

View file

@ -160,10 +160,11 @@ public class QRCodeEncoder {
public void run() {
String url = CHART_SERVER_URL + mPixelResolution + "x" + mPixelResolution + "&chl=" +
mContents;
AndroidHttpClient client = null;
try {
URI uri = new URI("http", url, null);
HttpGet get = new HttpGet(uri);
AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
client = AndroidHttpClient.newInstance(mUserAgent);
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
Bitmap image = BitmapFactory.decodeStream(entity.getContent());
@ -180,6 +181,10 @@ public class QRCodeEncoder {
Log.e(TAG, e.toString());
Message message = Message.obtain(mHandler, R.id.encode_failed);
message.sendToTarget();
} finally {
if (client != null) {
client.close();
}
}
}
}

View file

@ -294,6 +294,7 @@ public class SearchBookContentsActivity extends Activity {
} catch (IOException e) {
Log.e(TAG, e.toString());
}
client.close();
}
return cookie;
}