activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1496430 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
Date Tue, 25 Jun 2013 11:48:35 GMT
Author: dejanb
Date: Tue Jun 25 11:48:35 2013
New Revision: 1496430

URL: http://svn.apache.org/r1496430
Log:
https://issues.apache.org/jira/browse/AMQ-4598 - negative queue size after purge

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=1496430&r1=1496429&r2=1496430&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
Tue Jun 25 11:48:35 2013
@@ -563,6 +563,7 @@ public class Queue extends BaseDestinati
                         }
                     }
                 }
+
                 for (MessageReference ref : unAckedMessages) {
                     QueueMessageReference qmr = (QueueMessageReference) ref;
                     if (qmr.getLockOwner() == sub) {
@@ -581,7 +582,9 @@ public class Queue extends BaseDestinati
                             }
                         }
                     }
-                    redeliveredWaitingDispatch.addMessageLast(qmr);
+                    if (!qmr.isDropped()) {
+                        redeliveredWaitingDispatch.addMessageLast(qmr);
+                    }
                 }
                 if (sub instanceof QueueBrowserSubscription) {
                     ((QueueBrowserSubscription)sub).decrementQueueRef();
@@ -1800,13 +1803,15 @@ public class Queue extends BaseDestinati
     }
 
     private void dropMessage(QueueMessageReference reference) {
-        reference.drop();
-        destinationStatistics.getMessages().decrement();
-        pagedInMessagesLock.writeLock().lock();
-        try{
-            pagedInMessages.remove(reference.getMessageId());
-        }finally {
-            pagedInMessagesLock.writeLock().unlock();
+        if (!reference.isDropped()) {
+            reference.drop();
+            destinationStatistics.getMessages().decrement();
+            pagedInMessagesLock.writeLock().lock();
+            try {
+                pagedInMessages.remove(reference.getMessageId());
+            } finally {
+                pagedInMessagesLock.writeLock().unlock();
+            }
         }
     }
 

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java?rev=1496430&r1=1496429&r2=1496430&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
Tue Jun 25 11:48:35 2013
@@ -134,6 +134,14 @@ public class QueuePurgeTest extends Comb
         assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0,
                 proxy.getQueueSize());
         assertEquals("usage goes to duck", 0, proxy.getMemoryPercentUsage());
+        Message msg;
+        do {
+            msg = consumer.receive(1000);
+            if (msg != null) {
+                msg.acknowledge();
+            }
+        } while (msg != null);
+        assertEquals("Queue size not valid", 0, proxy.getQueueSize());
     }
 
     private QueueViewMBean getProxyToQueueViewMBean()



Mime
View raw message