From 6684f67c8725f717c6c39edc271366a965648962 Mon Sep 17 00:00:00 2001 From: Leonid Startsev Date: Thu, 5 Dec 2024 15:18:32 +0100 Subject: [PATCH] Handle missing system property without NPE (#2867) Fixes #2866 --- .../src/kotlinx/serialization/json/internal/ArrayPools.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/formats/json/jvmMain/src/kotlinx/serialization/json/internal/ArrayPools.kt b/formats/json/jvmMain/src/kotlinx/serialization/json/internal/ArrayPools.kt index 0d36c6c03b..9484addc56 100644 --- a/formats/json/jvmMain/src/kotlinx/serialization/json/internal/ArrayPools.kt +++ b/formats/json/jvmMain/src/kotlinx/serialization/json/internal/ArrayPools.kt @@ -8,8 +8,8 @@ package kotlinx.serialization.json.internal * (unlikely) problems with memory consumptions. */ private val MAX_CHARS_IN_POOL = runCatching { - System.getProperty("kotlinx.serialization.json.pool.size").toIntOrNull() -}.getOrNull() ?: 2 * 1024 * 1024 + System.getProperty("kotlinx.serialization.json.pool.size")?.toIntOrNull() +}.getOrNull() ?: (2 * 1024 * 1024) internal open class CharArrayPoolBase { private val arrays = ArrayDeque()