[ openjms-Bugs-1144026 ] ConcurrentModificationException in TopicDestinationCache

"SourceForge.net" <[email protected]> Tue, 30 Aug 2005 23:00:45 -0700
Newsgroups gmane.comp.java.openjms.devel
Message-ID <[email protected]>
Bugs item #1144026, was opened at 2005-02-19 07:02
Message generated for change (Comment added) made by tanderson
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=474136&aid=1144026&group_id=54559

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: server
Group: v0.7.6.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: pbezi (pbezi)
>Assigned to: Tim Anderson (tanderson)
Summary: ConcurrentModificationException in TopicDestinationCache

Initial Comment:
SYMPTOMS:

A java.util.ConcurrentModificationException (see below 
for the stack trace) is being thrown in the 
resolveExpiredMessage(MessageHandle handle) method 
of the 
org.exolab.jms.messagemgr.TopicDestinationCache class.

FOUND CAUSE:

The exception is thrown because the _consumers 
java.util.List object is being accessed in the 
multithreaded environment via the iterator in an 
unsynchronized block.
The protected _consumers member variable is declared 
in the parent class of 
org.exolab.jms.messagemgr.TopicDestinationCache - 
org.exolab.jms.messagemgr.DestinationCache as follows:

protected List _consumers =
        Collections.synchronizedList(new LinkedList());

This does not guarantee a thread safe access to the 
_consumers List object via the iterator obtained from 
the List.

RESOLUTION:

Modify the source code of the resolveExpiredMessage
(MessageHandle handle) method of the 
TopicDestinationCache class to include the iteration 
code in the synchronization block, synchronized on the 
list object:

synchronized (_consumers) {
// ..... iterate over _consumers

}

EXCEPTION STACK TRACE:
==========================================
java.util.ConcurrentModificationException

        at 
java.util.LinkedList$ListItr.checkForComodification
(LinkedList.java:548)

        at java.util.LinkedList$ListItr.next
(LinkedList.java:484)

        at 
org.exolab.jms.messagemgr.TopicDestinationCache.resolv
eExpiredMessage(TopicDestinationCache.java:381)

        at 
org.exolab.jms.messagemgr.DestinationCache.onLeaseExp
ired(DestinationCache.java:398)

        at 
org.exolab.jms.messagemgr.MessageLeaseHelper.onLease
Expired(MessageLeaseHelper.java:266)

        at 
org.exolab.jms.lease.BaseLease.notifyLeaseExpired
(BaseLease.java:161)

        at org.exolab.jms.lease.LeaseManager.expire
(LeaseManager.java:291)

        at org.exolab.jms.lease.LeaseManager.run
(LeaseManager.java:246)

        at java.lang.Thread.run(Thread.java:536)
==========================================

----------------------------------------------------------------------

>Comment By: Tim Anderson (tanderson)
Date: 2005-08-31 16:00

Message:
Logged In: YES 
user_id=557161

Fixed in CVS. Fix will be available in 0.7.7-alpha-2

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=474136&aid=1144026&group_id=54559


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf