Some fixes

This commit is contained in:
tom79 2019-12-15 17:34:34 +01:00
parent 904b3fa7db
commit 9629b694eb
1 changed files with 10 additions and 1 deletions

View File

@ -321,7 +321,8 @@ public class HttpsConnection {
public String get(String urlConnection) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException {
if (Build.VERSION.SDK_INT >= 21) {
OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS).cache(new Cache(context.getCacheDir(), cacheSize));
Cache cache = new Cache(context.getCacheDir(), cacheSize);
OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS).cache(cache);
if (proxy != null) {
builder.proxy(proxy);
}
@ -347,6 +348,14 @@ public class HttpsConnection {
} else {
throw new HttpsConnectionException(code, error);
}
}finally {
if (!cache.isClosed()) {
try {
cache.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} else {