diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/jarfs/FastJarHandler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/jarfs/FastJarHandler.kt index 766754defbc..df183eda624 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/jarfs/FastJarHandler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/jarfs/FastJarHandler.kt @@ -14,6 +14,7 @@ import java.io.File import java.io.FileNotFoundException import java.io.IOException import java.io.RandomAccessFile +import java.nio.ByteBuffer import java.nio.MappedByteBuffer import java.nio.channels.FileChannel @@ -26,8 +27,12 @@ class FastJarHandler(val fileSystem: FastJarFileSystem, path: String) : ZipHandl init { RandomAccessFile(file, "r").use { randomAccessFile -> val mappedByteBuffer = randomAccessFile.channel.map(FileChannel.MapMode.READ_ONLY, 0, randomAccessFile.length()) - ourEntryMap = mappedByteBuffer.parseCentralDirectory().associateBy { it.relativePath } - cachedManifest = ourEntryMap[MANIFEST_PATH]?.let(mappedByteBuffer::contentsToByteArray) + try { + ourEntryMap = mappedByteBuffer.parseCentralDirectory().associateBy { it.relativePath } + cachedManifest = ourEntryMap[MANIFEST_PATH]?.let(mappedByteBuffer::contentsToByteArray) + } finally { + mappedByteBuffer.unmapBuffer() + } } val entries: MutableMap = HashMap() @@ -167,9 +172,48 @@ private val cachedOpenFileHandles: FileAccessorCache