Skip to content

Commit 39a2669

Browse files
authored
Allow to shutdown SchemaDownloader (#6091)
* Allow to shutdown SchemaDownloader * revert unwanted change
1 parent 1bb2514 commit 39a2669

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

libraries/apollo-tooling/src/main/kotlin/com/apollographql/apollo/tooling/SchemaDownloader.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@ object SchemaDownloader {
189189
return data.graph.variant.latestPublication.schema.document
190190
}
191191

192+
fun shutdown() {
193+
SchemaHelper.client.dispatcher.executorService.shutdown()
194+
SchemaHelper.client.connectionPool.evictAll()
195+
}
196+
192197
inline fun <reified T> Any?.cast() = this as? T
193198
}

libraries/apollo-tooling/src/main/kotlin/com/apollographql/apollo/tooling/SchemaHelper.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ import javax.net.ssl.SSLSocketFactory
3131
import javax.net.ssl.X509TrustManager
3232

3333
internal object SchemaHelper {
34+
internal val client = OkHttpClient()
35+
3436
internal fun newOkHttpClient(insecure: Boolean): OkHttpClient {
3537
val connectTimeoutSeconds = System.getProperty("okHttp.connectTimeout", "600").toLong()
3638
val readTimeoutSeconds = System.getProperty("okHttp.readTimeout", "600").toLong()
37-
val clientBuilder = OkHttpClient.Builder()
39+
val clientBuilder = client.newBuilder()
3840
.connectTimeout(connectTimeoutSeconds, TimeUnit.SECONDS)
3941
.readTimeout(readTimeoutSeconds, TimeUnit.SECONDS)
4042

0 commit comments

Comments
 (0)