> However, wouldn't static analysis of the code be sufficient in this case?
> The code segment above is the only thing that is not protected by 
> synchronization, whilst
> every other use of this collection is.
>

Static analysis can identify the problem and the fix, but it doesn't
protect the change into the future.
A test case is the only reliable way to do this as it will capture the use case.

I committed a test case[1], it is not perfect but it does reproduce
about 80% of the time.

org.apache.activemq.JMSConsumerTest.testMessageListenerWithConsumerCanBeStoppedConcurently()

Bonnie, I hope this sort of matches your use case.

[1] 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSConsumerTest.java?view=markup

Reply via email to