From 3e64f9908ca3e48f6be63771411ec52543ea95e3 Mon Sep 17 00:00:00 2001 From: Leonid Stashevsky Date: Tue, 6 Sep 2022 11:41:37 +0200 Subject: [PATCH] Replace val with fun to fix init order (#3158) --- .../common/src/io/ktor/http/cio/internals/CharArrayPool.kt | 4 ++-- .../js/src/io/ktor/http/cio/internals/CharArrayPoolJs.kt | 2 +- .../jvm/src/io/ktor/http/cio/internals/CharArrayPoolJvm.kt | 2 +- .../src/io/ktor/http/cio/internals/CharArrayPoolPosix.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/CharArrayPool.kt b/ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/CharArrayPool.kt index a7d68cd9c97..993a2af0a43 100644 --- a/ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/CharArrayPool.kt +++ b/ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/CharArrayPool.kt @@ -6,7 +6,7 @@ package io.ktor.http.cio.internals import io.ktor.utils.io.pool.* -internal expect val DISABLE_CHAR_ARRAY_POOLING: Boolean +internal expect fun isPoolingDisabled(): Boolean internal const val CHAR_ARRAY_POOL_SIZE = 4096 @@ -15,7 +15,7 @@ internal const val CHAR_ARRAY_POOL_SIZE = 4096 */ internal const val CHAR_BUFFER_ARRAY_LENGTH: Int = 4096 / 2 -internal val CharArrayPool: ObjectPool = if (DISABLE_CHAR_ARRAY_POOLING) { +internal val CharArrayPool: ObjectPool = if (isPoolingDisabled()) { object : NoPoolImpl() { override fun borrow(): CharArray { return CharArray(CHAR_BUFFER_ARRAY_LENGTH) diff --git a/ktor-http/ktor-http-cio/js/src/io/ktor/http/cio/internals/CharArrayPoolJs.kt b/ktor-http/ktor-http-cio/js/src/io/ktor/http/cio/internals/CharArrayPoolJs.kt index 9fef1048944..5dfbcea2d8c 100644 --- a/ktor-http/ktor-http-cio/js/src/io/ktor/http/cio/internals/CharArrayPoolJs.kt +++ b/ktor-http/ktor-http-cio/js/src/io/ktor/http/cio/internals/CharArrayPoolJs.kt @@ -4,4 +4,4 @@ package io.ktor.http.cio.internals -internal actual val DISABLE_CHAR_ARRAY_POOLING: Boolean = false +internal actual fun isPoolingDisabled(): Boolean = false diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/internals/CharArrayPoolJvm.kt b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/internals/CharArrayPoolJvm.kt index 17a8db0e182..c3f7589b0b6 100644 --- a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/internals/CharArrayPoolJvm.kt +++ b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/internals/CharArrayPoolJvm.kt @@ -4,5 +4,5 @@ package io.ktor.http.cio.internals -internal actual val DISABLE_CHAR_ARRAY_POOLING: Boolean = +internal actual fun isPoolingDisabled(): Boolean = System.getProperty("ktor.internal.cio.disable.chararray.pooling")?.toBoolean() ?: false diff --git a/ktor-http/ktor-http-cio/posix/src/io/ktor/http/cio/internals/CharArrayPoolPosix.kt b/ktor-http/ktor-http-cio/posix/src/io/ktor/http/cio/internals/CharArrayPoolPosix.kt index 9fef1048944..5dfbcea2d8c 100644 --- a/ktor-http/ktor-http-cio/posix/src/io/ktor/http/cio/internals/CharArrayPoolPosix.kt +++ b/ktor-http/ktor-http-cio/posix/src/io/ktor/http/cio/internals/CharArrayPoolPosix.kt @@ -4,4 +4,4 @@ package io.ktor.http.cio.internals -internal actual val DISABLE_CHAR_ARRAY_POOLING: Boolean = false +internal actual fun isPoolingDisabled(): Boolean = false