stoicflame / enunciate

Build-time enhancement tool for Java-based Web services projects
http://enunciate.webcohesion.com/
Other
480 stars 200 forks source link

Started receiving `ConcurrentModificationException` after a dependancy library converted some `class` to `record` #1173

Closed christopher-nash closed 9 months ago

christopher-nash commented 1 year ago

We had a dependnat library convert several Java class to Java record. After they did that and we upgraded to that verion of their library, we started getting build failures doing a mvn clean install:

Failed to execute goal com.webcohesion.enunciate:enunciate-maven-plugin:2.15.1:assemble (assemble) 
on project ws: Error invoking Enunciate. java.util.ConcurrentModificationException -> [Help 1]

After doing a mvn -e -X clean install I found that it appears to happen somewhere related to Lombok:

at com.webcohesion.enunciate.modules.lombok.LombokDecoration.getLombokMethodDecorations (LombokDecoration.java:51)
Full Stack Trace ``` [ERROR] Failed to execute goal com.webcohesion.enunciate:enunciate-maven-plugin:2.15.1:docs (default) on project ws: Error invoking Enunciate.: java.util.ConcurrentModificationException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.webcohesion.enunciate:enunciate-maven-plugin:2.15.1:docs (default) on project ws: Error invoking Enunciate. at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.MojoExecutionException: Error invoking Enunciate. at com.webcohesion.enunciate.mojo.ConfigMojo.execute (ConfigMojo.java:443) at com.webcohesion.enunciate.mojo.DocsBaseMojo.execute (DocsBaseMojo.java:100) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.RuntimeException: java.util.ConcurrentModificationException at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper (JavacTaskImpl.java:168) at com.sun.tools.javac.api.JavacTaskImpl.doCall (JavacTaskImpl.java:100) at com.sun.tools.javac.api.JavacTaskImpl.call (JavacTaskImpl.java:94) at com.webcohesion.enunciate.Enunciate.run (Enunciate.java:656) at com.webcohesion.enunciate.mojo.ConfigMojo.execute (ConfigMojo.java:436) at com.webcohesion.enunciate.mojo.DocsBaseMojo.execute (DocsBaseMojo.java:100) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.util.ConcurrentModificationException at java.util.TreeMap.callMappingFunctionWithCheck (TreeMap.java:750) at java.util.TreeMap.computeIfAbsent (TreeMap.java:604) at com.webcohesion.enunciate.modules.lombok.LombokDecoration.getLombokMethodDecorations (LombokDecoration.java:51) at com.webcohesion.enunciate.modules.lombok.LombokDecoration.visitType (LombokDecoration.java:39) at com.webcohesion.enunciate.modules.lombok.LombokDecoration.visitType (LombokDecoration.java:27) at com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement.accept (DecoratedTypeElement.java:224) at com.webcohesion.enunciate.modules.lombok.LombokDecoration.applyTo (LombokDecoration.java:33) at com.webcohesion.enunciate.javac.decorations.element.DecoratedElement. (DecoratedElement.java:53) at com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement. (DecoratedTypeElement.java:52) at com.webcohesion.enunciate.javac.decorations.ElementDecorator.visitType (ElementDecorator.java:111) at com.webcohesion.enunciate.javac.decorations.ElementDecorator.visitType (ElementDecorator.java:30) at com.sun.tools.javac.code.Symbol$ClassSymbol.accept (Symbol.java:1575) at com.webcohesion.enunciate.javac.decorations.ElementDecorator.decorate (ElementDecorator.java:57) at com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType.asElement (DecoratedDeclaredType.java:44) at com.webcohesion.enunciate.javac.decorations.type.TypeVariableContext.resolveTypeVariables (TypeVariableContext.java:63) at com.webcohesion.enunciate.modules.spring_web.model.RequestMapping. (RequestMapping.java:239) at com.webcohesion.enunciate.modules.spring_web.model.SpringController.getRequestMappings (SpringController.java:165) at com.webcohesion.enunciate.modules.spring_web.model.SpringController. (SpringController.java:124) at com.webcohesion.enunciate.modules.spring_web.model.SpringController. (SpringController.java:55) at com.webcohesion.enunciate.modules.spring_web.model.SpringController. (SpringController.java:51) at com.webcohesion.enunciate.modules.spring_web.SpringWebModule.call (SpringWebModule.java:151) at com.webcohesion.enunciate.Enunciate.invokeModules (Enunciate.java:883) at com.webcohesion.enunciate.EnunciateAnnotationProcessor.process (EnunciateAnnotationProcessor.java:127) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor (JavacProcessingEnvironment.java:1023) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs (JavacProcessingEnvironment.java:939) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run (JavacProcessingEnvironment.java:1267) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing (JavacProcessingEnvironment.java:1382) at com.sun.tools.javac.main.JavaCompiler.processAnnotations (JavaCompiler.java:1234) at com.sun.tools.javac.main.JavaCompiler.compile (JavaCompiler.java:916) at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0 (JavacTaskImpl.java:104) at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper (JavacTaskImpl.java:152) at com.sun.tools.javac.api.JavacTaskImpl.doCall (JavacTaskImpl.java:100) at com.sun.tools.javac.api.JavacTaskImpl.call (JavacTaskImpl.java:94) at com.webcohesion.enunciate.Enunciate.run (Enunciate.java:656) at com.webcohesion.enunciate.mojo.ConfigMojo.execute (ConfigMojo.java:436) at com.webcohesion.enunciate.mojo.DocsBaseMojo.execute (DocsBaseMojo.java:100) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) ```

This project had declared

<dependencies>
  <dependency>
    <groupId>com.webcohesion.enunciate</groupId>
    <artifactId>enunciate-lombok</artifactId>
    <version>${enunciate.version}</version>
  </dependency>
</dependencies>

inside the

<plugin>
    <groupId>com.webcohesion.enunciate</groupId>
    <artifactId>enunciate-maven-plugin</artifactId>

in both the root and the module pom.

Removing that dependency (which in our case it doesn't look like was being used for anything) seems to have fixed the issue.

stoicflame commented 9 months ago

Moved from TreeMap to ConcurrentHashMap implementation.

stoicflame commented 9 months ago

Enunciate 2.16.1 has been released.