activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1292858 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java test/java/org/apache/activemq/broker/policy/AbortSlowConsumerTest.java
Date Thu, 23 Feb 2012 17:13:38 GMT
Author: gtully
Date: Thu Feb 23 17:13:37 2012
New Revision: 1292858

URL: http://svn.apache.org/viewvc?rev=1292858&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3737 - Possible leak in ManangedRegionBroker unregisterDestination.
relates to: https://issues.apache.org/activemq/browse/AMQ-2741 - a leak indeed, or more than
a mbean

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java?rev=1292858&r1=1292857&r2=1292858&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java
Thu Feb 23 17:13:37 2012
@@ -346,11 +346,10 @@ public class ManagedRegionBroker extends
 
     protected void unregisterDestination(ObjectName key) throws Exception {
 
-        DestinationView view = null;
-        removeAndRemember(topics, key, view);
-        removeAndRemember(queues, key, view);
-        removeAndRemember(temporaryQueues, key, view);
-        removeAndRemember(temporaryTopics, key, view);
+        DestinationView view = removeAndRemember(topics, key, null);
+        view = removeAndRemember(queues, key, view);
+        view = removeAndRemember(temporaryQueues, key, view);
+        view = removeAndRemember(temporaryTopics, key, view);
         if (registeredMBeans.remove(key)) {
             try {
                 managementContext.unregisterMBean(key);
@@ -417,11 +416,12 @@ public class ManagedRegionBroker extends
         }
     }
 
-    private void removeAndRemember(Map<ObjectName, DestinationView> map, ObjectName
key, DestinationView view) {
+    private DestinationView removeAndRemember(Map<ObjectName, DestinationView> map,
ObjectName key, DestinationView view) {
         DestinationView candidate = map.remove(key);
         if (candidate != null && view == null) {
             view = candidate;
         }
+        return candidate != null ? candidate : view;
     }
 
     protected void registerSubscription(ObjectName key, ConsumerInfo info, SubscriptionKey
subscriptionKey, SubscriptionView view) throws Exception {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerTest.java?rev=1292858&r1=1292857&r2=1292858&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/policy/AbortSlowConsumerTest.java
Thu Feb 23 17:13:37 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.broker.policy;
 
+import javax.management.InstanceNotFoundException;
 import junit.framework.Test;
 import org.apache.activemq.JmsMultipleClientsTestSupport;
 import org.apache.activemq.broker.BrokerService;
@@ -37,6 +38,7 @@ import javax.jms.Session;
 import javax.management.ObjectName;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.TabularData;
+import java.lang.reflect.UndeclaredThrowableException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
@@ -173,6 +175,17 @@ public class AbortSlowConsumerTest exten
         slowOnes = abortPolicy.getSlowConsumers();
         assertEquals("no slow consumers left", 0, slowOnes.size());
 
+        // verify mbean gone with destination
+        broker.getAdminView().removeTopic(amqDest.getPhysicalName());
+
+        try {
+            abortPolicy.getSlowConsumers();
+            fail("expect not found post destination removal");
+        } catch(UndeclaredThrowableException expected) {
+            assertTrue("correct exception: " + expected.getCause(),
+                    expected.getCause() instanceof InstanceNotFoundException);
+        }
+
     }
 
 



Mime
View raw message