Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2555

ConcurrentModificationException while destroying context

XMLWordPrintable

    • Hide

      1. Deploy attached weld-bug-8.0.0.war on Wildfly 14.0.1.Final (I think the problem is in Weld 3.0.5.Final so WildFly version might not matter)
      2. Open http://localhost:8080/weld-bug/rs/myresource
      3. Don't let yourself be fooled by the 200 answer of the request
      4. Check server.log for ConcurrentModificationException

      Show
      1. Deploy attached weld-bug-8.0.0.war on Wildfly 14.0.1.Final (I think the problem is in Weld 3.0.5.Final so WildFly version might not matter) 2. Open http://localhost:8080/weld-bug/rs/myresource 3. Don't let yourself be fooled by the 200 answer of the request 4. Check server.log for ConcurrentModificationException

      A ConcurrentModificationException is thrown if beans are created while the context is being destroyed.

      Two beans are currently in the context while it is being destroyed:
      MyRequestScopedBean
      MyOtherRequestScopedBean

      On @PreDestory of MyRequestScopedBean a third bean MyRequestScopedDataHolder is called. This bean is created because it was not used before.

      When the destory logic in AbstractContext continues it failes with a ConcurrentModificationException because the underlying BeanStore (or more accuratly the backing HashMap) has been changed.

      This bug is also depending on the version of the deployed app because it influences the key hash. This means there are situations where it works and situations where it won't work (depending of the "order" in the HashMap).

      I created an example which uses JAX-RS but it is also reproduceable using MDBs.

              Unassigned Unassigned
              djm82 Daniel Munzinger (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: