Ignore ProcessCancelledException in VirtualFileKotlinClass

This commit is contained in:
Vladimir Ilmov
2020-07-30 15:19:51 +02:00
parent 3de32e13ea
commit 60dfa8cc84
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.kotlin
import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder.Result.KotlinClass
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
@@ -41,8 +42,7 @@ class VirtualFileKotlinClass private constructor(
override fun getFileContents(): ByteArray {
try {
return file.contentsToByteArray()
}
catch (e: IOException) {
} catch (e: IOException) {
LOG.error(renderFileReadingErrorMessage(file), e)
throw rethrow(e)
}
@@ -71,18 +71,18 @@ class VirtualFileKotlinClass private constructor(
return@time kotlinJvmBinaryClass?.let { KotlinClass(it, byteContent) }
?: KotlinClassFinder.Result.ClassFileContent(byteContent)
}
}
catch (e: FileNotFoundException) {
} catch (e: FileNotFoundException) {
// Valid situation. User can delete jar file.
}
catch (e: Throwable) {
LOG.warn(renderFileReadingErrorMessage(file))
} catch (e: ProcessCanceledException) {
// Valid situation.
} catch (e: Throwable) {
LOG.warn(renderFileReadingErrorMessage(file), e)
}
null
}
}
private fun renderFileReadingErrorMessage(file: VirtualFile): String =
"Could not read file: ${file.path}; size in bytes: ${file.length}; file type: ${file.fileType.name}"
"Could not read file: ${file.path}; size in bytes: ${file.length}; file type: ${file.fileType.name}"
}
}