activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r961272 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Date Wed, 07 Jul 2010 07:35:31 GMT
Author: rajdavies
Date: Wed Jul  7 07:35:31 2010
New Revision: 961272

URL: http://svn.apache.org/viewvc?rev=961272&view=rev
Log:
fixed a potential hole around lock usage

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=961272&r1=961271&r2=961272&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Wed Jul  7 07:35:31 2010
@@ -1677,23 +1677,19 @@ public class Queue extends BaseDestinati
             }
             // Only add new messages, not already pagedIn to avoid multiple
             // dispatch attempts
-            pagedInMessagesLock.readLock().lock();
+            pagedInMessagesLock.writeLock().lock();
             try {
                 resultList = new ArrayList<QueueMessageReference>(result.size());
                 for (QueueMessageReference ref : result) {
-                    if (!pagedInMessages.containsKey(ref.getMessageId())) {
-                        pagedInMessagesLock.readLock().unlock();
-                        pagedInMessagesLock.writeLock().lock();
+                    if (!pagedInMessages.containsKey(ref.getMessageId())) {            
                         pagedInMessages.put(ref.getMessageId(), ref);
-                        pagedInMessagesLock.readLock().lock();
-                        pagedInMessagesLock.writeLock().unlock();
                         resultList.add(ref);
                     } else {
                         ref.decrementReferenceCount();
                     }
                 }
             } finally {
-                pagedInMessagesLock.readLock().unlock();
+                pagedInMessagesLock.writeLock().unlock();
             }
         } else {
             // Avoid return null list, if condition is not validated



Mime
View raw message