activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject git commit: AMQ-5265 - fix race condition for task
Date Wed, 09 Jul 2014 14:45:05 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk d4a376d88 -> bf1c57b33


AMQ-5265 - fix race condition for task


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/bf1c57b3
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/bf1c57b3
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/bf1c57b3

Branch: refs/heads/trunk
Commit: bf1c57b33d2c013a8096b5a1982a00c20ce25909
Parents: d4a376d
Author: Jeff Genender <jgenender@savoirtech.com>
Authored: Tue Jul 8 15:05:41 2014 -0600
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Wed Jul 9 16:43:30 2014 +0200

----------------------------------------------------------------------
 .../network/MBeanBridgeDestination.java         | 32 ++++++++------------
 1 file changed, 12 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/bf1c57b3/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
b/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
index 583fab7..bab5574 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
@@ -21,6 +21,7 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.management.ObjectName;
+
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.jmx.AnnotatedMBean;
 import org.apache.activemq.broker.jmx.BrokerMBeanSupport;
@@ -144,32 +145,23 @@ public class MBeanBridgeDestination {
 
     private void purgeInactiveDestinationView(Map<ActiveMQDestination, NetworkDestinationView>
map) {
         long time = System.currentTimeMillis() - networkBridgeConfiguration.getGcSweepTime();
-        Map<ActiveMQDestination, NetworkDestinationView> gc = null;
         for (Map.Entry<ActiveMQDestination, NetworkDestinationView> entry : map.entrySet())
{
             if (entry.getValue().getLastAccessTime() <= time) {
-                if (gc == null) {
-                    gc = new HashMap<ActiveMQDestination, NetworkDestinationView>();
-                }
-                gc.put(entry.getKey(), entry.getValue());
-            }
-        }
-
-        if (gc != null) {
-            for (Map.Entry<ActiveMQDestination, NetworkDestinationView> entry : gc.entrySet())
{
-                map.remove(entry.getKey());
-                ObjectName objectName = destinationObjectNameMap.get(entry.getKey());
-                if (objectName != null) {
-                    try {
-                        if (objectName != null) {
-                            brokerService.getManagementContext().unregisterMBean(objectName);
+                synchronized (destinationObjectNameMap) {
+                    map.remove(entry.getKey());
+                    ObjectName objectName = destinationObjectNameMap.remove(entry.getKey());
+                    if (objectName != null) {
+                        try {
+                            if (objectName != null) {
+                                brokerService.getManagementContext().unregisterMBean(objectName);
+                            }
+                        } catch (Throwable e) {
+                            LOG.debug("Network bridge could not be unregistered in JMX: {}",
e.getMessage(), e);
                         }
-                    } catch (Throwable e) {
-                        LOG.debug("Network bridge could not be unregistered in JMX: {}",
e.getMessage(), e);
                     }
+                    entry.getValue().close();
                 }
-                entry.getValue().close();
             }
         }
     }
-
 }


Mime
View raw message