Skip to content

Commit 33b7e5e

Browse files
arthurpalvesdanikula
authored andcommitted
Catch NullPointerException to avoid crash due to unsupported async disconnects on Android L (which uses an outdated okhttp version)
1 parent 0aad13f commit 33b7e5e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/src/main/java/com/danikula/videocache/HttpUrlSource.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ private int readSourceAvailableBytes(HttpURLConnection connection, int offset, i
7676
@Override
7777
public void close() throws ProxyCacheException {
7878
if (connection != null) {
79-
connection.disconnect();
79+
try {
80+
connection.disconnect();
81+
} catch (NullPointerException e) {
82+
// https://github.com/danikula/AndroidVideoCache/issues/32
83+
// https://github.com/danikula/AndroidVideoCache/issues/29
84+
throw new ProxyCacheException("Error disconnecting HttpUrlConnection", e);
85+
}
8086
}
8187
}
8288

0 commit comments

Comments
 (0)