Check also the cause of throwable for OOM exception
Sometimes OOM exception is the cause of some higher-level one exception in compilation. ^KT-51116 Fixed
This commit is contained in:
@@ -121,12 +121,17 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
||||
return COMPILATION_ERROR
|
||||
} catch (t: Throwable) {
|
||||
MessageCollectorUtil.reportException(collector, t)
|
||||
return if (t is OutOfMemoryError) OOM_ERROR else INTERNAL_ERROR
|
||||
return if (t is OutOfMemoryError || t.hasOOMCause()) OOM_ERROR else INTERNAL_ERROR
|
||||
} finally {
|
||||
collector.flush()
|
||||
}
|
||||
}
|
||||
|
||||
private fun Throwable.hasOOMCause(): Boolean = when (cause) {
|
||||
is OutOfMemoryError -> true
|
||||
else -> cause?.hasOOMCause() ?: false
|
||||
}
|
||||
|
||||
private fun MessageCollector.reportCompilationCancelled(e: CompilationCanceledException) {
|
||||
if (e !is IncrementalNextRoundException) {
|
||||
report(INFO, "Compilation was canceled", null)
|
||||
|
||||
Reference in New Issue
Block a user