Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification exception in ImmutableClassNode.enableWriteProtection(...) #132

Closed
bradbeck opened this issue Aug 11, 2015 · 1 comment
Closed

Comments

@bradbeck
Copy link

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.

@bradbeck
Copy link
Author

Proposed fix: #133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants