Skip to content

Commit 611c406

Browse files
committed
Close cache and connnections on shutdown
1 parent b3bcf0f commit 611c406

File tree

1 file changed

+7
-3
lines changed
  • src/main/kotlin/com/gabrielfeo/gradle/enterprise/api

1 file changed

+7
-3
lines changed

src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/Api.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ var accessToken: () -> String = {
3333
}
3434

3535
/**
36-
* Shutdown the internal OkHttp client, releasing resources and allowing the program to finish
37-
* before the client's idle timeout.
36+
* Shutdown the internal client, releasing resources and allowing the program to
37+
* finish before the client's idle timeout.
3838
*
3939
* https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary
4040
*/
4141
fun shutdown() {
42-
okHttpClient.dispatcher.executorService.shutdownNow()
42+
okHttpClient.run {
43+
dispatcher.executorService.shutdown()
44+
connectionPool.evictAll();
45+
cache?.close();
46+
}
4347
}
4448

4549
/**

0 commit comments

Comments
 (0)