Details
-
Bug
-
Resolution: Done
-
Major
-
JBossAS-4.0.1 Final
-
None
Description
SpySession.java has a concurrency bug. Once in a while when closing it, I get the following exception:
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.remove(AbstractList.java:434)
at org.jboss.mq.SpySession.close(SpySession.java:461)
at com.hmsonline.common.ejb.JMSUtil$4.callback(JMSUtil.java:104)
at com.hmsonline.common.ejb.JMSUtil$7.run(JMSUtil.java:153)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
I stared at SpySession.java for a while trying to figure out how this could happen, because the close method makes a local copy of the producers Set. Then I noticed that 5 lines before the exception occurs, the iterator "i" gets reassigned:
i = unacknowledgedMessages.iterator();
and no copy is made of that list and it is not thread-safe.