Skip to content

Commit 66de71f

Browse files
committed
OkHttpClientHelper: Set OkHttp's logging to "fine" in ORT's "debug" log level
This allows to see where leaked connections were allocated. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 0da1625 commit 66de71f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

utils/core/src/main/kotlin/OkHttpClientHelper.kt

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import java.io.File
2323
import java.io.IOException
2424
import java.time.Duration
2525
import java.util.concurrent.ConcurrentHashMap
26+
import java.util.logging.Level
27+
import java.util.logging.Logger
2628

2729
import kotlin.coroutines.resume
2830
import kotlin.coroutines.resumeWithException
@@ -72,6 +74,11 @@ object OkHttpClientHelper {
7274
private val defaultClient by lazy {
7375
installAuthenticatorAndProxySelector()
7476

77+
if (log.delegate.isDebugEnabled) {
78+
// Allow to track down leaked connections.
79+
Logger.getLogger(OkHttpClient::javaClass.name).level = Level.FINE
80+
}
81+
7582
val cacheDirectory = ortDataDirectory.resolve(CACHE_DIRECTORY)
7683
val cache = Cache(cacheDirectory, MAX_CACHE_SIZE_IN_BYTES)
7784
val specs = listOf(ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS, ConnectionSpec.CLEARTEXT)

0 commit comments

Comments
 (0)