activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [08/16] activemq git commit: AMQ-5265 - fix race condition for task
Date Tue, 16 Dec 2014 22:09:56 GMT
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/569a6771
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/569a6771
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/569a6771

Branch: refs/heads/activemq-5.10.x
Commit: 569a67714d3d1c4e63553c19a2d92f9d2413360b
Parents: 73cb029
Author: Jeff Genender <jgenender@savoirtech.com>
Authored: Tue Jul 8 15:05:41 2014 -0600
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Mon Dec 15 19:09:58 2014 -0500

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/569a6771/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