FastJarFS: fix behavior on invalid zip files
"emulate" the ZipHandler - log error and ignore invalid file #KT-55712 fixed
This commit is contained in:
committed by
Space Team
parent
b415aa7446
commit
46c8cbe1bb
@@ -4,12 +4,14 @@
|
||||
*/
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler.jarfs
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.RandomAccessFile
|
||||
import java.nio.channels.FileChannel
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
class FastJarHandler(val fileSystem: FastJarFileSystem, path: String) {
|
||||
private val myRoot: VirtualFile?
|
||||
@@ -25,7 +27,10 @@ class FastJarHandler(val fileSystem: FastJarFileSystem, path: String) {
|
||||
entries = try {
|
||||
mappedByteBuffer.parseCentralDirectory()
|
||||
} catch (e: Exception) {
|
||||
throw IllegalStateException("Error while reading '${file.path}': $e", e)
|
||||
// copying the behavior of ArchiveHandler (and therefore ZipHandler)
|
||||
// TODO: consider propagating to compiler error or warning, but take into account that both javac and K1 simply ignore invalid jars in such cases
|
||||
Logger.getInstance(this::class.java).warn("Error while reading zip file: ${file.path}: $e", e)
|
||||
emptyList()
|
||||
}
|
||||
cachedManifest =
|
||||
entries.singleOrNull { StringUtil.equals(MANIFEST_PATH, it.relativePath) }
|
||||
|
||||
Reference in New Issue
Block a user