[ 
https://issues.apache.org/activemq/browse/AMQ-1631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=41755#action_41755
 ] 

Matthew Roy commented on AMQ-1631:
----------------------------------

I see frequent concurrency errors due to the dispose method not synchronizing 
on the deliveredMessages linkedList.  Here is a patch that I think addresses 
the issue:

Index: 
/work/src/activemq/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
===================================================================
--- 
/work/src/activemq/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
     (revision 639741)
+++ 
/work/src/activemq/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
     (working copy)
@@ -659,8 +659,10 @@
                         session.connection.rollbackDuplicate(this, 
old.getMessage());
                     }
                 }
+            } 
+            synchronized(deliveredMessages) {
+                deliveredMessages.clear();
             }
-            deliveredMessages.clear();
             List<MessageDispatch> list = unconsumedMessages.removeAll();
             if (!this.info.isBrowser()) {
                 for (MessageDispatch old : list) {


> Concurrency Issue in MessageConsumer's deliveredMessages within dispose
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1631
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1631
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.0.0
>            Reporter: Matthew Roy
>            Assignee: Rob Davies
>             Fix For: 5.1.0
>
>
> The LinkedList can be modified concurrently - see 
> http://www.nabble.com/NPE-while-consuming-messages-to12301153s2354.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to