From 71c0d441f90718a0760c9efcb136b84b0ef557ab Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Tue, 31 May 2011 18:36:44 +0000 Subject: [PATCH] fix for: https://issues.apache.org/jira/browse/AMQ-3337 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1129835 13f79535-47bb-0310-9956-ffa450edef68 --- .../broker/jmx/ManagedRegionBroker.java | 39 ++++++++++++------- .../apache/activemq/broker/jmx/MBeanTest.java | 4 ++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java b/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java index a2f2d689dc..17c1130b79 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java @@ -348,19 +348,23 @@ public class ManagedRegionBroker extends RegionBroker { } protected void registerProducer(ObjectName key, ActiveMQDestination dest, ProducerView view) throws Exception { - if (dest.isQueue()) { - if (dest.isTemporary()) { - temporaryQueueProducers.put(key, view); + + if (dest != null) { + if (dest.isQueue()) { + if (dest.isTemporary()) { + temporaryQueueProducers.put(key, view); + } else { + queueProducers.put(key, view); + } } else { - queueProducers.put(key, view); - } - } else { - if (dest.isTemporary()) { - temporaryTopicProducers.put(key, view); - } else { - topicProducers.put(key, view); + if (dest.isTemporary()) { + temporaryTopicProducers.put(key, view); + } else { + topicProducers.put(key, view); + } } } + try { AnnotatedMBean.registerMBean(managementContext, view, key); registeredMBeans.add(key); @@ -499,7 +503,7 @@ public class ManagedRegionBroker extends RegionBroker { } protected void addInactiveSubscription(SubscriptionKey key, SubscriptionInfo info) { - Hashtable map = brokerObjectName.getKeyPropertyList(); + Hashtable map = brokerObjectName.getKeyPropertyList(); try { ObjectName objectName = new ObjectName(brokerObjectName.getDomain() + ":" + "BrokerName=" + map.get("BrokerName") + "," + "Type=Subscription," + "active=false," + "name=" + JMXSupport.encodeObjectNamePart(key.toString()) + ""); @@ -671,8 +675,17 @@ public class ManagedRegionBroker extends RegionBroker { // Build the object name for the producer info Hashtable map = brokerObjectName.getKeyPropertyList(); - String destinationType = "destinationType=" + producerInfo.getDestination().getDestinationTypeAsString(); - String destinationName = "destinationName=" + JMXSupport.encodeObjectNamePart(producerInfo.getDestination().getPhysicalName()); + String destinationType = "destinationType="; + String destinationName = "destinationName="; + + if (producerInfo.getDestination() == null) { + destinationType += "NOTSET"; + destinationName += "NOTSET"; + } else { + destinationType += producerInfo.getDestination().getDestinationTypeAsString(); + destinationName += JMXSupport.encodeObjectNamePart(producerInfo.getDestination().getPhysicalName()); + } + String clientId = "clientId=" + JMXSupport.encodeObjectNamePart(connectionClientId); String producerId = "producerId=" + JMXSupport.encodeObjectNamePart(producerInfo.getProducerId().toString()); diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java index ad8c8b1c0e..1b75495440 100644 --- a/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java @@ -613,6 +613,10 @@ public class MBeanTest extends EmbeddedBrokerTestSupport { assertEquals("topic1 Producer count", 0, topic1.getProducerCount()); assertEquals("topic2 Producer count", 0, topic2.getProducerCount()); + MessageProducer producer4 = session.createProducer(null); + producer4.close(); + Thread.sleep(500); + assertEquals("broker Topic Producer count", 0, broker.getTopicProducers().length); }