Uploaded image for project: 'Hibernate ORM'
  1. HHH-7537

ConcurrentModificationException thrown while flushing changes to database

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 4.1.5
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Hibernate 4.1.5, Postgres 9, Postgres82 Dialect, Java 6, IntelliJ 11, OS X 10.8
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      A ConcurrentModificationException is being thrown while Hibernate is flushing changes to the database. Specifically, it occurs while it is persisting new "collections" (i.e. one-to-many) entities.

      Stacktrace:

      java.util.ConcurrentModificationException
      at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
      at java.util.AbstractList$Itr.next(AbstractList.java:343)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:353)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:279)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1214)
      at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:986)

      I do have a Post-Insert, Update, Collection Recreate, Collection Update listener where ConcurrentModificationException is only occurring if this listener is in place. However, the listener and actions it takes doesn't modify any entities or make save changes. So I am bit miffed.

      This is occurring in what appears to be a single threaded environment. At the very least the entity manager is thread local which means the hibernate events list shouldn't be modified concurrently.

      It leads me to believe that the list is being modified within the for loop somehow...

        Attachments

          Activity

            People

            • Votes:
              4 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: