Some fixes
This commit is contained in:
parent
904b3fa7db
commit
9629b694eb
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue