From commits-return-51486-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Mon May 21 22:40:50 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id ADAF318063A for ; Mon, 21 May 2018 22:40:49 +0200 (CEST) Received: (qmail 93872 invoked by uid 500); 21 May 2018 20:40:48 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 93863 invoked by uid 99); 21 May 2018 20:40:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 May 2018 20:40:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AAB34E0B14; Mon, 21 May 2018 20:40:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: <175fc9301eb94d0ab882f2d1d20f6eff@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: AMQ-6968 Ensure that the correct exception is thrown Date: Mon, 21 May 2018 20:40:48 +0000 (UTC) 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 Authored: Mon May 21 16:39:50 2018 -0400 Committer: Timothy Bish 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 activeTempDestinations = new ConcurrentHashMap(); + public final ConcurrentMap 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 sessions = new CopyOnWriteArrayList(); - private final CopyOnWriteArrayList connectionConsumers = new CopyOnWriteArrayList(); - private final CopyOnWriteArrayList transportListeners = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList sessions = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList connectionConsumers = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList transportListeners = new CopyOnWriteArrayList<>(); // Maps ConsumerIds to ActiveMQConsumer objects - private final ConcurrentMap dispatchers = new ConcurrentHashMap(); - private final ConcurrentMap producers = new ConcurrentHashMap(); + private final ConcurrentMap dispatchers = new ConcurrentHashMap<>(); + private final ConcurrentMap 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 trustedPackages = new ArrayList(); + private List trustedPackages = new ArrayList<>(); private boolean trustAllPackages = false; - private int connectResponseTimeout; + private int connectResponseTimeout; /** * Construct an ActiveMQConnection @@ -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 options = new HashMap(info.getDestination().getOptions()); + Map 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 options = new HashMap(consumerInfo.getDestination().getOptions()); + Map 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; + } }