[JS IR] IC close input streams

^KT-51853 Fixed
This commit is contained in:
Alexander Korepanov
2022-04-06 15:44:54 +03:00
committed by Space
parent 92d9c5b150
commit c4bb445c01
2 changed files with 6 additions and 2 deletions
@@ -18,7 +18,9 @@ class SrcFileArtifact(val srcFilePath: String, private val fragment: JsIrProgram
return fragment
}
return astArtifact?.ifExists { readBytes() }?.let {
deserializer.deserialize(ByteArrayInputStream(it))
ByteArrayInputStream(it).use { byteStream ->
deserializer.deserialize(byteStream)
}
}
}
@@ -21,7 +21,9 @@ internal fun File.recreate() {
}
internal inline fun <T> File.useCodedInputIfExists(f: CodedInputStream.() -> T) = ifExists {
CodedInputStream.newInstance(FileInputStream(this)).f()
FileInputStream(this).use {
CodedInputStream.newInstance(it).f()
}
}
internal inline fun File.useCodedOutput(f: CodedOutputStream.() -> Unit) {