From 611c406ae80b7cd460a6c174847768d4f6110115 Mon Sep 17 00:00:00 2001 From: Gabriel Feo Date: Tue, 3 Jan 2023 14:02:55 +0000 Subject: [PATCH] Close cache and connnections on shutdown --- .../kotlin/com/gabrielfeo/gradle/enterprise/api/Api.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/Api.kt b/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/Api.kt index a49d2c20..b0ddcd76 100644 --- a/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/Api.kt +++ b/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api/Api.kt @@ -33,13 +33,17 @@ var accessToken: () -> String = { } /** - * Shutdown the internal OkHttp client, releasing resources and allowing the program to finish - * before the client's idle timeout. + * Shutdown the internal client, releasing resources and allowing the program to + * finish before the client's idle timeout. * * https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary */ fun shutdown() { - okHttpClient.dispatcher.executorService.shutdownNow() + okHttpClient.run { + dispatcher.executorService.shutdown() + connectionPool.evictAll(); + cache?.close(); + } } /**