From 332a961405a4c36735314e77b49dc5e89be3a22a Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Date: Wed, 4 Sep 2024 19:52:59 -0400 Subject: [PATCH] Close the KSP caches files after reading them (cherry picked from commit 1290ef8cfcee5027456002cf4f2bf0abffdcca1a) --- .../kotlin/com/google/devtools/ksp/common/PersistentMap.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/common/PersistentMap.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/common/PersistentMap.kt index 9b7811ebfa..65d5bc7b04 100644 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/common/PersistentMap.kt +++ b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/common/PersistentMap.kt @@ -53,7 +53,9 @@ abstract class PersistentMap( @OptIn(ExperimentalSerializationApi::class) protected fun deserialize(serializer: KSerializer>, storage: File): MutableMap { return if (storage.exists()) { - Json.decodeFromStream(serializer, storage.inputStream()).toMutableMap() + storage.inputStream().use { + Json.decodeFromStream(serializer, it).toMutableMap() + } } else { mutableMapOf() }