mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Work around Android NPE observed in the wild
git-svn-id: https://zxing.googlecode.com/svn/trunk@2451 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
4c4ebbe0c5
commit
db7afc66b6
|
@ -110,8 +110,16 @@ public final class HttpHelper {
|
|||
Log.w(TAG, "Bad URI? " + uri);
|
||||
throw new IOException(iae);
|
||||
}
|
||||
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
throw new IOException("Bad HTTP response: " + connection.getResponseCode());
|
||||
int responseCode;
|
||||
try {
|
||||
responseCode = connection.getResponseCode();
|
||||
} catch (NullPointerException npe) {
|
||||
// this is maybe this Android bug: http://code.google.com/p/android/issues/detail?id=15554
|
||||
Log.w(TAG, "Bad URI? " + uri);
|
||||
throw new IOException(npe);
|
||||
}
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
throw new IOException("Bad HTTP response: " + responseCode);
|
||||
}
|
||||
Log.i(TAG, "Consuming " + uri);
|
||||
return consume(connection, maxChars);
|
||||
|
|
Loading…
Reference in a new issue