Skip to content

Commit

Permalink
Close the KSP caches files after reading them
Browse files Browse the repository at this point in the history
  • Loading branch information
ansman authored and ting-yuan committed Sep 5, 2024
1 parent 88c2886 commit 1290ef8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ abstract class PersistentMap<K, V>(
@OptIn(ExperimentalSerializationApi::class)
protected fun <K, V> deserialize(serializer: KSerializer<Map<K, V>>, storage: File): MutableMap<K, V> {
return if (storage.exists()) {
Json.decodeFromStream(serializer, storage.inputStream()).toMutableMap()
storage.inputStream().use {
Json.decodeFromStream(serializer, it).toMutableMap()
}
} else {
mutableMapOf()
}
Expand Down

0 comments on commit 1290ef8

Please sign in to comment.