mirror of https://github.com/apache/activemq.git
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
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1292858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
14350af90c
commit
2290502bc9
|
@ -346,11 +346,10 @@ public class ManagedRegionBroker extends RegionBroker {
|
||||||
|
|
||||||
protected void unregisterDestination(ObjectName key) throws Exception {
|
protected void unregisterDestination(ObjectName key) throws Exception {
|
||||||
|
|
||||||
DestinationView view = null;
|
DestinationView view = removeAndRemember(topics, key, null);
|
||||||
removeAndRemember(topics, key, view);
|
view = removeAndRemember(queues, key, view);
|
||||||
removeAndRemember(queues, key, view);
|
view = removeAndRemember(temporaryQueues, key, view);
|
||||||
removeAndRemember(temporaryQueues, key, view);
|
view = removeAndRemember(temporaryTopics, key, view);
|
||||||
removeAndRemember(temporaryTopics, key, view);
|
|
||||||
if (registeredMBeans.remove(key)) {
|
if (registeredMBeans.remove(key)) {
|
||||||
try {
|
try {
|
||||||
managementContext.unregisterMBean(key);
|
managementContext.unregisterMBean(key);
|
||||||
|
@ -417,11 +416,12 @@ public class ManagedRegionBroker extends RegionBroker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
DestinationView candidate = map.remove(key);
|
||||||
if (candidate != null && view == null) {
|
if (candidate != null && view == null) {
|
||||||
view = candidate;
|
view = candidate;
|
||||||
}
|
}
|
||||||
|
return candidate != null ? candidate : view;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerSubscription(ObjectName key, ConsumerInfo info, SubscriptionKey subscriptionKey, SubscriptionView view) throws Exception {
|
protected void registerSubscription(ObjectName key, ConsumerInfo info, SubscriptionKey subscriptionKey, SubscriptionView view) throws Exception {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker.policy;
|
package org.apache.activemq.broker.policy;
|
||||||
|
|
||||||
|
import javax.management.InstanceNotFoundException;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.apache.activemq.JmsMultipleClientsTestSupport;
|
import org.apache.activemq.JmsMultipleClientsTestSupport;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
@ -37,6 +38,7 @@ import javax.jms.Session;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
|
import java.lang.reflect.UndeclaredThrowableException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -173,6 +175,17 @@ public class AbortSlowConsumerTest extends JmsMultipleClientsTestSupport impleme
|
||||||
slowOnes = abortPolicy.getSlowConsumers();
|
slowOnes = abortPolicy.getSlowConsumers();
|
||||||
assertEquals("no slow consumers left", 0, slowOnes.size());
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue