java.util.ConcurrentModificationException

Hibernate JIRA | Robin Sander | 6 years ago
  1. 0

    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}

    Hibernate JIRA | 6 years ago | Robin Sander
    java.util.ConcurrentModificationException
  2. 0

    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}

    Hibernate JIRA | 6 years ago | Robin Sander
    java.util.ConcurrentModificationException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    ConcurrentModificationException when reading JMS queue mBean on JBoss

    GitHub | 5 years ago | mkuthan
    java.util.ConcurrentModificationException
  5. 0

    Java Concurrency Issue with Iterator and Nested Hashtable

    Stack Overflow | 6 years ago | Bill Spaulding
    java.util.ConcurrentModificationException

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.util.ConcurrentModificationException

      No message provided

      at java.util.HashMap$HashIterator.nextEntry()
    2. Java RT
      HashMap$ValueIterator.next
      1. java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
      2. java.util.HashMap$ValueIterator.next(HashMap.java:822)
      2 frames
    3. org.hibernate.jpamodelgen
      JPAMetaModelEntityProcessor.process
      1. org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.createMetaModelClasses(JPAMetaModelEntityProcessor.java:153)
      2. org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.process(JPAMetaModelEntityProcessor.java:133)
      2 frames
    4. Java Tools
      JavacTaskImpl.call
      1. com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:625)
      2. com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:554)
      3. com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:699)
      4. com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
      5. com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
      6. com.sun.tools.javac.main.Main.compile(Main.java:353)
      7. com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
      7 frames
    5. org.bsc.maven
      AbstractAnnotationProcessorMojo.execute
      1. org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:261)
      2. org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:129)
      2 frames
    6. Maven Plugin
      DefaultPluginManager.executeMojo
      1. org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
      1 frame