You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/09/06 13:48:17 UTC
svn commit: r1807483 -
/sling/trunk/bundles/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
Author: cziegeler
Date: Wed Sep 6 13:48:17 2017
New Revision: 1807483
URL: http://svn.apache.org/viewvc?rev=1807483&view=rev
Log:
SLING-7111 : Compiler creates class files even if compilation fails
Modified:
sling/trunk/bundles/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
Modified: sling/trunk/bundles/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java?rev=1807483&r1=1807482&r2=1807483&view=diff
==============================================================================
--- sling/trunk/bundles/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java (original)
+++ sling/trunk/bundles/commons/compiler/src/main/java/org/apache/sling/commons/compiler/impl/EclipseJavaCompiler.java Wed Sep 6 13:48:17 2017
@@ -69,7 +69,7 @@ public class EclipseJavaCompiler impleme
private IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
/** the static policy. */
- private final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
+ private final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
/**
* Get the classloader for the compilation.
@@ -286,14 +286,16 @@ public class EclipseJavaCompiler impleme
}
}
}
- ClassFile[] classFiles = result.getClassFiles();
- for (int i = 0; i < classFiles.length; i++) {
- ClassFile classFile = classFiles[i];
- String className = CharOperation.toString(classFile.getCompoundName());
- try {
- this.write(className, classFile.getBytes());
- } catch (IOException e) {
- this.errorHandler.onError("Unable to write class file: " + e.getMessage(), className, 0, 0);
+ if ( this.errorHandler.getErrors() == null ) {
+ ClassFile[] classFiles = result.getClassFiles();
+ for (int i = 0; i < classFiles.length; i++) {
+ ClassFile classFile = classFiles[i];
+ String className = CharOperation.toString(classFile.getCompoundName());
+ try {
+ this.write(className, classFile.getBytes());
+ } catch (IOException e) {
+ this.errorHandler.onError("Unable to write class file: " + e.getMessage(), className, 0, 0);
+ }
}
}
}