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

Unsynchronized iteration in AbstractNamingScheme causes ConcurrentModificationException

XMLWordPrintable

      The following test failure occurred in org.jboss.weld.environment.se.test.context.session.BoundSessionContextTest.testConcurrentCalls:

      java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
      	at org.jboss.weld.environment.se.test.context.session.BoundSessionContextTest.testConcurrentCalls(BoundSessionContextTest.java:66)
      Caused by: java.util.ConcurrentModificationException: null
      	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
      	at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
      	at com.google.common.collect.Iterators$8.computeNext(Iterators.java:735)
      	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
      	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
      	at com.google.common.collect.Lists.newArrayList(Lists.java:144)
      	at com.google.common.collect.Collections2$FilteredCollection.toArray(Collections2.java:234)
      	at java.util.ArrayList.<init>(ArrayList.java:177)
      	at org.jboss.weld.context.beanstore.AbstractNamingScheme.filterIds(AbstractNamingScheme.java:74)
      	at org.jboss.weld.context.beanstore.AttributeBeanStore.getPrefixedAttributeNames(AttributeBeanStore.java:198)
      	at org.jboss.weld.context.beanstore.AttributeBeanStore.attach(AttributeBeanStore.java:95)
      	at org.jboss.weld.context.AbstractBoundContext.activate(AbstractBoundContext.java:66)
      	at org.jboss.weld.environment.se.test.context.session.BoundSessionContextTest$ConcurrentCall.call(BoundSessionContextTest.java:92)
      	at org.jboss.weld.environment.se.test.context.session.BoundSessionContextTest$ConcurrentCall.call(BoundSessionContextTest.java:75)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      AbstractNamingScheme defers filtering of IDs to the guava Collections2 class which does not synchronize iteration over the given collection.
      Iteration over standard Java collections (HashMap in this case) must be synchronized(..) for thread safety, even if the supplied collection is an instance of Collections.synchronizedXXX().

              rhn-engineering-jharting Jozef Hartinger
              rsmeral Ron Šmeral (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: