activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: AMQ-6968 Ensure that the correct exception is thrown
Date Mon, 21 May 2018 20:40:48 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.15.x ea1894c7e -> 5403ad2e8


AMQ-6968 Ensure that the correct exception is thrown

Allow the original exception that triggered the failure to be thrown
from the packet send methods
(cherry picked from commit db8c771b2a37ad16d789f546507b6329221f4c7a)


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

Branch: refs/heads/activemq-5.15.x
Commit: 5403ad2e826048d021f8feee888015c45c979514
Parents: ea1894c
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon May 21 16:39:50 2018 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon May 21 16:40:43 2018 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/ActiveMQConnection.java | 50 ++++++++++++--------
 1 file changed, 29 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/5403ad2e/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
index 9f12344..5a8596b 100644
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java
@@ -117,7 +117,7 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
 
     private static final Logger LOG = LoggerFactory.getLogger(ActiveMQConnection.class);
 
-    public final ConcurrentMap<ActiveMQTempDestination, ActiveMQTempDestination> activeTempDestinations
= new ConcurrentHashMap<ActiveMQTempDestination, ActiveMQTempDestination>();
+    public final ConcurrentMap<ActiveMQTempDestination, ActiveMQTempDestination> activeTempDestinations
= new ConcurrentHashMap<>();
 
     protected boolean dispatchAsync=true;
     protected boolean alwaysSessionAsync = true;
@@ -170,13 +170,13 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
     private final AtomicBoolean closing = new AtomicBoolean(false);
     private final AtomicBoolean closed = new AtomicBoolean(false);
     private final AtomicBoolean transportFailed = new AtomicBoolean(false);
-    private final CopyOnWriteArrayList<ActiveMQSession> sessions = new CopyOnWriteArrayList<ActiveMQSession>();
-    private final CopyOnWriteArrayList<ActiveMQConnectionConsumer> connectionConsumers
= new CopyOnWriteArrayList<ActiveMQConnectionConsumer>();
-    private final CopyOnWriteArrayList<TransportListener> transportListeners = new
CopyOnWriteArrayList<TransportListener>();
+    private final CopyOnWriteArrayList<ActiveMQSession> sessions = new CopyOnWriteArrayList<>();
+    private final CopyOnWriteArrayList<ActiveMQConnectionConsumer> connectionConsumers
= new CopyOnWriteArrayList<>();
+    private final CopyOnWriteArrayList<TransportListener> transportListeners = new
CopyOnWriteArrayList<>();
 
     // Maps ConsumerIds to ActiveMQConsumer objects
-    private final ConcurrentMap<ConsumerId, ActiveMQDispatcher> dispatchers = new ConcurrentHashMap<ConsumerId,
ActiveMQDispatcher>();
-    private final ConcurrentMap<ProducerId, ActiveMQMessageProducer> producers = new
ConcurrentHashMap<ProducerId, ActiveMQMessageProducer>();
+    private final ConcurrentMap<ConsumerId, ActiveMQDispatcher> dispatchers = new ConcurrentHashMap<>();
+    private final ConcurrentMap<ProducerId, ActiveMQMessageProducer> producers = new
ConcurrentHashMap<>();
     private final LongSequenceGenerator sessionIdGenerator = new LongSequenceGenerator();
     private final SessionId connectionSessionId;
     private final LongSequenceGenerator consumerIdGenerator = new LongSequenceGenerator();
@@ -208,9 +208,9 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
     private int maxThreadPoolSize = DEFAULT_THREAD_POOL_SIZE;
     private RejectedExecutionHandler rejectedTaskHandler = null;
 
-    private List<String> trustedPackages = new ArrayList<String>();
+    private List<String> trustedPackages = new ArrayList<>();
     private boolean trustAllPackages = false;
-	private int connectResponseTimeout;
+    private int connectResponseTimeout;
 
     /**
      * Construct an <code>ActiveMQConnection</code>
@@ -818,7 +818,7 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
 
         // Allows the options on the destination to configure the consumerInfo
         if (info.getDestination().getOptions() != null) {
-            Map<String, String> options = new HashMap<String, String>(info.getDestination().getOptions());
+            Map<String, String> options = new HashMap<>(info.getDestination().getOptions());
             IntrospectionSupport.setProperties(this.info, options, "consumer.");
         }
 
@@ -1237,7 +1237,7 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
 
         // Allows the options on the destination to configure the consumerInfo
         if (consumerInfo.getDestination().getOptions() != null) {
-            Map<String, String> options = new HashMap<String, String>(consumerInfo.getDestination().getOptions());
+            Map<String, String> options = new HashMap<>(consumerInfo.getDestination().getOptions());
             IntrospectionSupport.setProperties(consumerInfo, options, "consumer.");
         }
 
@@ -1340,11 +1340,11 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
                         } catch (Exception e) {
                             exception = e;
                         }
-                        if(exception!=null) {
+                        if (exception != null) {
                             if ( exception instanceof JMSException) {
                                 onComplete.onException((JMSException) exception);
                             } else {
-                                if (isClosed()||closing.get()) {
+                                if (isClosed() || closing.get()) {
                                     LOG.debug("Received an exception but connection is closing");
                                 }
                                 JMSException jmsEx = null;
@@ -1355,9 +1355,13 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
                                 }
                                 // dispose of transport for security exceptions on connection
initiation
                                 if (exception instanceof SecurityException && command
instanceof ConnectionInfo){
-                                    forceCloseOnSecurityException(exception);
+                                    try {
+                                        forceCloseOnSecurityException(exception);
+                                    } catch (Throwable t) {
+                                        // We throw the original error from the ExceptionResponse
instead.
+                                    }
                                 }
-                                if (jmsEx !=null) {
+                                if (jmsEx != null) {
                                     onComplete.onException(jmsEx);
                                 }
                             }
@@ -1391,7 +1395,7 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
                     if (er.getException() instanceof JMSException) {
                         throw (JMSException)er.getException();
                     } else {
-                        if (isClosed()||closing.get()) {
+                        if (isClosed() || closing.get()) {
                             LOG.debug("Received an exception but connection is closing");
                         }
                         JMSException jmsEx = null;
@@ -1401,9 +1405,13 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
                             LOG.error("Caught an exception trying to create a JMSException
for " +er.getException(),e);
                         }
                         if (er.getException() instanceof SecurityException && command
instanceof ConnectionInfo){
-                            forceCloseOnSecurityException(er.getException());
+                            try {
+                                forceCloseOnSecurityException(er.getException());
+                            } catch (Throwable t) {
+                                // We throw the original error from the ExceptionResponse
instead.
+                            }
                         }
-                        if (jmsEx !=null) {
+                        if (jmsEx != null) {
                             throw jmsEx;
                         }
                     }
@@ -2570,10 +2578,10 @@ public class ActiveMQConnection implements Connection, TopicConnection,
QueueCon
     }
 
     public int getConnectResponseTimeout() {
-    	return connectResponseTimeout;
+        return connectResponseTimeout;
     }
 
-	public void setConnectResponseTimeout(int connectResponseTimeout) {
-		this.connectResponseTimeout = connectResponseTimeout;
-	}
+    public void setConnectResponseTimeout(int connectResponseTimeout) {
+        this.connectResponseTimeout = connectResponseTimeout;
+    }
 }


Mime
View raw message