highsource / jaxb2-basics

Useful plugins and tools for JAXB2.
BSD 2-Clause "Simplified" License
109 stars 54 forks source link

ConcurrentModificationException w/ jax-xew-plugin 1.7 #72

Closed mattrpav closed 4 years ago

mattrpav commented 8 years ago

While using jaxb-xew-plugin 1.7 and jaxb2-basics 0.13.1 a ConcurrentModificationException is thrown.

Downgrading jaxb-xew-plugin to 1.2 resolves the issue

Linked to jaxb-xew-plugin issue: https://github.com/dmak/jaxb-xew-plugin/issues/48

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.806 s [INFO] Finished at: 2016-07-27T14:07:46-05:00 [INFO] Final Memory: 18M/310M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate (generate) on project aaa.bbb.ccc: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed. ConcurrentModificationException -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.

Full stacktrace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate (generate) on project aaa.bbb.ccc: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 20 more Caused by: java.util.ConcurrentModificationException at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:394) at java.util.LinkedHashMap$ValueIterator.next(LinkedHashMap.java:409) at org.jvnet.jaxb2_commons.plugin.codegenerator.AbstractCodeGeneratorPlugin.run(AbstractCodeGeneratorPlugin.java:72) at com.sun.tools.xjc.model.Model.generateCode(Model.java:292) at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:66) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:41) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:505) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:328) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 21 more

mattrpav commented 8 years ago

To recreate:

mvn generate-sources

To work around:

Edit pom.xml and set jaxb.xew.plugin = 1.2 mvn generate-sources

Sample project: jaxb2-xew-bug.zip

dmak commented 8 years ago

Question to jaxb2-basics team: Why FieldUtils.getPossibleTypes():204 uses outline model and not the code model to retrieve types? Also I think that to implement such simple thing as equals() or hashCode() one don't need to collect all possible types: there is one and only one type.

highsource commented 8 years ago

@dmak I can't say exactly anymore, but I think you can't retrieve this information from the rendered code model. I think you'd only get "lowes common denominator" there instead of individual possible type. Generally, I prefer not to infer anything from the rendered code model as it is, well, a rendered projection of the model/outline.

dmak commented 8 years ago

I understand your position but from other side if the class has T field, what are the other options for the type to use in equals()? Isn't it simply T tmp = getField(); if (tmp != null) { boolean result = tmp.equals(other.getField()); }?

mattrpav commented 4 years ago

Closing this issue.. fixed on the xew side. Project works with xew 1.11 (and possibly earlier. Bug marked fixed in xew 1.8)