From 48413bf09da1aa5335ed1c1c30d85e8a9252c2a2 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 2 May 2018 11:50:42 +0200 Subject: [PATCH] fix regression: do not treat cancelled exception as a compiler internal error --- .../jps/incremental/java/JavaBuilder.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index c24c28e49368..6ea527947227 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -298,6 +298,7 @@ public class JavaBuilder extends ModuleLevelBuilder { context.processMessage(new ProgressMessage("Parsing java... [" + chunk.getPresentableShortName() + "]")); final int filesCount = files.size(); + boolean compiledOk = true; if (filesCount > 0) { LOG.info("Compiling " + filesCount + " java files; module: " + chunkName + (chunk.containsTests() ? " (tests)" : "")); if (LOG.isDebugEnabled()) { @@ -313,24 +314,24 @@ public class JavaBuilder extends ModuleLevelBuilder { LOG.debug(" " + file.getAbsolutePath()); } } - boolean compiledOk = false; try { compiledOk = compileJava(context, chunk, files, classpath, platformCp, srcPath, diagnosticSink, outputSink, compilingTool, hasModules); } finally { filesWithErrors = diagnosticSink.getFilesWithErrors(); - if (!compiledOk && diagnosticSink.getErrorCount() == 0) { - // unexpected exception occurred or compiler did not output any errors for some reason - diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "Compilation failed: internal java compiler error")); - } - if (diagnosticSink.getErrorCount() > 0) { - diagnosticSink.report(new JpsInfoDiagnostic("Errors occurred while compiling module '" + chunkName + "'")); - } } } context.checkCanceled(); + if (!compiledOk && diagnosticSink.getErrorCount() == 0) { + // unexpected exception occurred or compiler did not output any errors for some reason + diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "Compilation failed: internal java compiler error")); + } + if (diagnosticSink.getErrorCount() > 0) { + diagnosticSink.report(new JpsInfoDiagnostic("Errors occurred while compiling module '" + chunkName + "'")); + } + if (!Utils.PROCEED_ON_ERROR_KEY.get(context, Boolean.FALSE) && diagnosticSink.getErrorCount() > 0) { throw new StopBuildException( "Compilation failed: errors: " + diagnosticSink.getErrorCount() + "; warnings: " + diagnosticSink.getWarningCount()