Polishing

This commit is contained in:
Juergen Hoeller
2018-07-24 15:17:33 +02:00
parent 484addb4f8
commit 2ae2249842
4 changed files with 37 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
@@ -118,8 +119,9 @@ public class OkHttp3ClientHttpRequestFactory
public void destroy() throws IOException {
if (this.defaultClient) {
// Clean up the client if we created it in the constructor
if (this.client.cache() != null) {
this.client.cache().close();
Cache cache = this.client.cache();
if (cache != null) {
cache.close();
}
this.client.dispatcher().executorService().shutdown();
}