Environment
- groovy 2.4.3
- groovy-eclipse-compiler 2.9.2-01
- groovy-eclipse-batch 2.4.3-01
- takari-smart-builder 0.4.0
- maven 3.3.3
Description
Running a parallel maven build with "mvn --builder smart -T1C clean install -DskipTests" occasionally causes the following error:
[ERROR] /*
[ERROR] ^
[ERROR] General error during class generation: java.lang.UnsupportedOperationException
[ERROR]
[ERROR] java.lang.UnsupportedOperationException
[ERROR] at java.util.Collections$UnmodifiableMap.put(Collections.java:1457)
[ERROR] at org.codehaus.groovy.ast.ImmutableClassNode.enableWriteProtection(ImmutableClassNode.java:128)
[ERROR] at org.codehaus.groovy.ast.ImmutableClassNode.getDeclaredMethods(ImmutableClassNode.java:120)
[ERROR] at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:1004)
[ERROR] at org.codehaus.groovy.classgen.ClassCompletionVerifier.checkMethodForWeakerAccessPrivileges(ClassCompletionVerifier.java:369)
[ERROR] at org.codehaus.groovy.classgen.ClassCompletionVerifier.checkMethodsForWeakerAccess(ClassCompletionVerifier.java:266)
[ERROR] at org.codehaus.groovy.classgen.ClassCompletionVerifier.visitClass(ClassCompletionVerifier.java:66)
[ERROR] at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:857)
[ERROR] at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:909)
[ERROR] at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1221)
[ERROR] at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:651)
[ERROR] at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:629)
[ERROR] at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:606)
[ERROR] at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:202)
[ERROR] at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:1711)
[ERROR] at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:838)
[ERROR] at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:137)
[ERROR] at java.lang.Thread.run(Thread.java:745)
ImmutableClassNode.java:128
It appears that at least two threads think that writeProtected == false and both try to enter the synchronized enableWriteProtection() method. One will block
while the other is creating the unmodifiableMap. But when the blocked thread then executes the enableWriteProtection() method it will generate the above error.
One solution is to make writeProtected volatile and check it again inside the enableWriteProtection() method.
Environment
Description
Running a parallel maven build with "
mvn --builder smart -T1C clean install -DskipTests" occasionally causes the following error:ImmutableClassNode.java:128It appears that at least two threads think that
writeProtected == falseand both try to enter the synchronizedenableWriteProtection()method. One will blockwhile the other is creating the
unmodifiableMap. But when the blocked thread then executes theenableWriteProtection()method it will generate the above error.One solution is to make
writeProtectedvolatile and check it again inside theenableWriteProtection()method.