activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1090320 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: broker/ network/ thread/ transport/discovery/simple/ util/
Date Fri, 08 Apr 2011 16:16:59 GMT
Author: gtully
Date: Fri Apr  8 16:16:58 2011
New Revision: 1090320

URL: http://svn.apache.org/viewvc?rev=1090320&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3276 - ConcurrentModificationException in embedded
5.5.0 broker. Rework https://issues.apache.org/jira/browse/AMQ-3219 - no need to set the context
on thread creation as mdc impl uses an InheritableThreadLocal. This should avoid the concurrent
mod, little test in mods to org.apache.activemq.bugs.AMQ2902Test

Removed:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MDCHelper.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DedicatedTaskRunner.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DeterministicTaskRunner.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/PooledTaskRunner.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Fri Apr  8 16:16:58 2011
@@ -2109,11 +2109,9 @@ public class BrokerService implements Se
                         connector.setBrokerURL(getDefaultSocketURIString());
                     }
                     if (networkConnectorStartExecutor != null) {
-                        final Map context = MDCHelper.getCopyOfContextMap();
                         networkConnectorStartExecutor.execute(new Runnable() {
                             public void run() {
                                 try {
-                                    MDCHelper.setContextMap(context);
                                     LOG.info("Async start of " + connector);
                                     connector.start();
                                 } catch(Exception e) {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Fri Apr  8 16:16:58 2011
@@ -943,12 +943,10 @@ public class TransportConnection impleme
                 cs.getContext().getStopping().set(true);
             }
             try {
-                final Map context = MDCHelper.getCopyOfContextMap();
                 DefaultThreadPools.getDefaultTaskRunnerFactory().execute(new Runnable(){
                     public void run() {
                         serviceLock.writeLock().lock();
                         try {
-                            MDCHelper.setContextMap(context);
                             doStop();
                         } catch (Throwable e) {
                             LOG.debug("Error occured while shutting down a connection to
'" + transport.getRemoteAddress()

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
Fri Apr  8 16:16:58 2011
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.regex.Pattern;
@@ -39,7 +38,6 @@ import org.apache.activemq.transport.Tra
 import org.apache.activemq.transport.TransportServer;
 import org.apache.activemq.transport.discovery.DiscoveryAgent;
 import org.apache.activemq.transport.discovery.DiscoveryAgentFactory;
-import org.apache.activemq.util.MDCHelper;
 import org.apache.activemq.util.ServiceStopper;
 import org.apache.activemq.util.ServiceSupport;
 import org.slf4j.Logger;
@@ -209,13 +207,11 @@ public class TransportConnector implemen
         brokerInfo.setPeerBrokerInfos(broker.getPeerBrokerInfos());
         brokerInfo.setFaultTolerantConfiguration(broker.isFaultTolerantConfiguration());
         brokerInfo.setBrokerURL(getServer().getConnectURI().toString());
-        final Map context = MDCHelper.getCopyOfContextMap();
         getServer().setAcceptListener(new TransportAcceptListener() {
             public void onAccept(final Transport transport) {
                 try {
                     DefaultThreadPools.getDefaultTaskRunnerFactory().execute(new Runnable()
{
                         public void run() {
-                            MDCHelper.setContextMap(context);
                             try {
                                 Connection connection = createConnection(transport);
                                 connection.start();

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
Fri Apr  8 16:16:58 2011
@@ -236,10 +236,8 @@ public abstract class DemandForwardingBr
     }
 
     protected void triggerLocalStartBridge() throws IOException {
-        final Map context = MDCHelper.getCopyOfContextMap();
         asyncTaskRunner.execute(new Runnable() {
             public void run() {
-                MDCHelper.setContextMap(context);
                 final String originalName = Thread.currentThread().getName();
                 Thread.currentThread().setName("StartLocalBridge: localBroker=" + localBroker);
                 try {
@@ -254,10 +252,8 @@ public abstract class DemandForwardingBr
     }
 
     protected void triggerRemoteStartBridge() throws IOException {
-        final Map context = MDCHelper.getCopyOfContextMap();
         asyncTaskRunner.execute(new Runnable() {
             public void run() {
-                MDCHelper.setContextMap(context);
                 final String originalName = Thread.currentThread().getName();
                 Thread.currentThread().setName("StartRemotelBridge: localBroker=" + localBroker);
                 try {
@@ -388,11 +384,9 @@ public abstract class DemandForwardingBr
                 try {
                     remoteBridgeStarted.set(false);
                     final CountDownLatch sendShutdown = new CountDownLatch(1);
-                    final Map map = MDCHelper.getCopyOfContextMap();
                     asyncTaskRunner.execute(new Runnable() {
                         public void run() {
                             try {
-                                MDCHelper.setContextMap(map);
                                 localBroker.oneway(new ShutdownInfo());
                                 sendShutdown.countDown();
                                 remoteBroker.oneway(new ShutdownInfo());
@@ -434,10 +428,8 @@ public abstract class DemandForwardingBr
                 LOG.warn("Network connection between " + localBroker + " and " + remoteBroker
+ " shutdown due to a remote error: " + error);
             }
             LOG.debug("The remote Exception was: " + error, error);
-            final Map map = MDCHelper.getCopyOfContextMap();
             asyncTaskRunner.execute(new Runnable() {
                 public void run() {
-                    MDCHelper.setContextMap(map);
                     ServiceSupport.dispose(getControllingService());
                 }
             });
@@ -652,10 +644,8 @@ public abstract class DemandForwardingBr
         if (!disposed.get()) {
             LOG.info("Network connection between " + localBroker + " and " + remoteBroker
+ " shutdown due to a local error: " + error);
             LOG.debug("The local Exception was:" + error, error);
-            final Map map = MDCHelper.getCopyOfContextMap();
             asyncTaskRunner.execute(new Runnable() {
                 public void run() {
-                    MDCHelper.setContextMap(map);
                     ServiceSupport.dispose(getControllingService());
                 }
             });
@@ -681,10 +671,8 @@ public abstract class DemandForwardingBr
             subscriptionMapByLocalId.remove(sub.getLocalInfo().getConsumerId());
 
             // continue removal in separate thread to free up this thread for outstanding
responses
-            final Map map = MDCHelper.getCopyOfContextMap();
             asyncTaskRunner.execute(new Runnable() {
                 public void run() {
-                    MDCHelper.setContextMap(map);
                     sub.waitForCompletion();
                     try {
                         localBroker.oneway(sub.getLocalInfo().createRemoveCommand());

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DedicatedTaskRunner.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DedicatedTaskRunner.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DedicatedTaskRunner.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DedicatedTaskRunner.java
Fri Apr  8 16:16:58 2011
@@ -16,10 +16,6 @@
  */
 package org.apache.activemq.thread;
 
-import org.apache.activemq.util.MDCHelper;
-
-import java.util.Map;
-
 /**
  * 
  */
@@ -35,10 +31,8 @@ class DedicatedTaskRunner implements Tas
 
     public DedicatedTaskRunner(Task task, String name, int priority, boolean daemon) {
         this.task = task;
-        final Map context = MDCHelper.getCopyOfContextMap();
         thread = new Thread(name) {
             public void run() {
-                MDCHelper.setContextMap(context);
                 runTask();
             }
         };

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DeterministicTaskRunner.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DeterministicTaskRunner.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DeterministicTaskRunner.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/DeterministicTaskRunner.java
Fri Apr  8 16:16:58 2011
@@ -16,10 +16,6 @@
  */
 package org.apache.activemq.thread;
 
-import org.apache.activemq.util.MDCHelper;
-import org.slf4j.MDC;
-
-import java.util.Map;
 import java.util.concurrent.Executor;
 
 /**
@@ -39,13 +35,9 @@ public class DeterministicTaskRunner imp
     public DeterministicTaskRunner(Executor executor, Task task) {
         this.executor = executor;
         this.task = task;
-        final Map context = MDCHelper.getCopyOfContextMap();
         this.runable = new Runnable() {
             public void run() {
                 Thread.currentThread();
-                if (context != null) {
-                    MDCHelper.setContextMap(context);
-                }
                 runTask();
             }
         };

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/PooledTaskRunner.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/PooledTaskRunner.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/PooledTaskRunner.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/PooledTaskRunner.java
Fri Apr  8 16:16:58 2011
@@ -16,9 +16,6 @@
  */
 package org.apache.activemq.thread;
 
-import org.apache.activemq.util.MDCHelper;
-
-import java.util.Map;
 import java.util.concurrent.Executor;
 
 /**
@@ -39,10 +36,8 @@ class PooledTaskRunner implements TaskRu
         this.executor = executor;
         this.maxIterationsPerRun = maxIterationsPerRun;
         this.task = task;
-        final Map context = MDCHelper.getCopyOfContextMap();
         runable = new Runnable() {
             public void run() {
-                MDCHelper.setContextMap(context);
                 runningThread = Thread.currentThread();
                 try {
                     runTask();

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java?rev=1090320&r1=1090319&r2=1090320&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
Fri Apr  8 16:16:58 2011
@@ -18,18 +18,12 @@ package org.apache.activemq.transport.di
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.Map;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.command.DiscoveryEvent;
 import org.apache.activemq.thread.DefaultThreadPools;
 import org.apache.activemq.transport.discovery.DiscoveryAgent;
 import org.apache.activemq.transport.discovery.DiscoveryListener;
-import org.apache.activemq.util.MDCHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -112,12 +106,9 @@ public class SimpleDiscoveryAgent implem
         if (event.failed.compareAndSet(false, true)) {
 
             listener.onServiceRemove(event);
-            final Map context = MDCHelper.getCopyOfContextMap();
             DefaultThreadPools.getDefaultTaskRunnerFactory().execute(new Runnable() {
                 public void run() {
 
-                    MDCHelper.setContextMap(context);
-
                     // We detect a failed connection attempt because the service
                     // fails right
                     // away.



Mime
View raw message