[hibernate-issues] [Hibernate-JIRA] Commented: (METAGEN-49) JPAMetaModelEntityProcessor.createMetaModelClasses calls remove within foreach loop (causing a ConcurrentModificationException)

Hardy Ferentschik (JIRA) noreply at atlassian.com
Thu Dec 2 10:37:14 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39261#action_39261 ] 

Hardy Ferentschik commented on METAGEN-49:
------------------------------------------

Right. I guess we do a 1.1.1 micro release then :)

> JPAMetaModelEntityProcessor.createMetaModelClasses calls remove within foreach loop (causing a ConcurrentModificationException)
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: METAGEN-49
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-49
>             Project: Hibernate Metamodel Generator
>          Issue Type: Bug
>          Components: processor
>    Affects Versions: 1.1.0.Final
>         Environment: Hibernate 3.6.0, Java 6 (1.6.0_22), Mac OS X 10.6.5
>            Reporter: Robin Sander
>            Assignee: Hardy Ferentschik
>         Attachments: metagen49.zip
>
>
> Running the annotation processor causes a ConcurrentModificationException.
> I'm using Maven and the maven-processor-plugin 1.3.7 but from looking into the sources I guess this bug occurs in any environment.
> JPAMetaModelEntityProcessor.createMetaModelClasses iterates of a Collection<MetaEntity> using a foreach loop and calls remove
> on the same collection which causes a ConcurrentModificationException.
> Obviously an iterator should be used instead.
> Here are the lines concerned:
> {code:java} 
>  Collection<MetaEntity> toProcessEntities = context.getMetaEmbeddables();
>  while ( !toProcessEntities.isEmpty() ) {
>   Set<MetaEntity> processedEntities = new HashSet<MetaEntity>();
>   int toProcessCountBeforeLoop = toProcessEntities.size();
>   for ( MetaEntity entity : toProcessEntities ) {
>     // see METAGEN-36
>     if ( generatedModelClasses.contains( entity.getQualifiedName() ) ) {
>       toProcessEntities.remove( entity );  // XXX this causes a ConcurrentModificationException
>       continue;
>   }
>  ...
> {code}
> Here is the stacktrace:
> {code}
> ...
> [INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.1.0.Final
> An annotation processor threw an uncaught exception.
> Consult the following stack trace for details.
> java.util.ConcurrentModificationException
> 	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
> 	at java.util.HashMap$ValueIterator.next(HashMap.java:822)
> 	at org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.createMetaModelClasses(JPAMetaModelEntityProcessor.java:153)
> 	at org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.process(JPAMetaModelEntityProcessor.java:133)
> 	at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:625)
> 	at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:554)
> 	at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:699)
> 	at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
> 	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
> 	at com.sun.tools.javac.main.Main.compile(Main.java:353)
> 	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
> 	at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:261)
> 	at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:129)
> 	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list