mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
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:
parent
56644b1af2
commit
de83fdf806
|
@ -160,10 +160,11 @@ public class QRCodeEncoder {
|
||||||
public void run() {
|
public void run() {
|
||||||
String url = CHART_SERVER_URL + mPixelResolution + "x" + mPixelResolution + "&chl=" +
|
String url = CHART_SERVER_URL + mPixelResolution + "x" + mPixelResolution + "&chl=" +
|
||||||
mContents;
|
mContents;
|
||||||
|
AndroidHttpClient client = null;
|
||||||
try {
|
try {
|
||||||
URI uri = new URI("http", url, null);
|
URI uri = new URI("http", url, null);
|
||||||
HttpGet get = new HttpGet(uri);
|
HttpGet get = new HttpGet(uri);
|
||||||
AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
|
client = AndroidHttpClient.newInstance(mUserAgent);
|
||||||
HttpResponse response = client.execute(get);
|
HttpResponse response = client.execute(get);
|
||||||
HttpEntity entity = response.getEntity();
|
HttpEntity entity = response.getEntity();
|
||||||
Bitmap image = BitmapFactory.decodeStream(entity.getContent());
|
Bitmap image = BitmapFactory.decodeStream(entity.getContent());
|
||||||
|
@ -180,6 +181,10 @@ public class QRCodeEncoder {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
Message message = Message.obtain(mHandler, R.id.encode_failed);
|
Message message = Message.obtain(mHandler, R.id.encode_failed);
|
||||||
message.sendToTarget();
|
message.sendToTarget();
|
||||||
|
} finally {
|
||||||
|
if (client != null) {
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,6 +294,7 @@ public class SearchBookContentsActivity extends Activity {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
|
client.close();
|
||||||
}
|
}
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue