You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/01/23 19:05:08 UTC

[1/2] activemq-artemis git commit: ARTEMIS-1415 potential JMS bridge conn leak

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 81324e0ca -> acd20790f


ARTEMIS-1415 potential JMS bridge conn leak


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

Branch: refs/heads/master
Commit: 3658d62810d250fea6858b9654006030efbe107c
Parents: 81324e0
Author: Justin Bertram <jb...@apache.org>
Authored: Tue Jan 23 09:40:29 2018 -0600
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jan 23 14:01:30 2018 -0500

----------------------------------------------------------------------
 .../artemis/jms/bridge/impl/JMSBridgeImpl.java  | 97 +++++++++++---------
 1 file changed, 54 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3658d628/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
index 4d9b04e..034af0e 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
@@ -954,65 +954,76 @@ public final class JMSBridgeImpl implements JMSBridge {
                                        final String clientID,
                                        final boolean isXA,
                                        boolean isSource) throws Exception {
-      Connection conn;
+      Connection conn = null;
 
-      Object cf = cff.createConnectionFactory();
+      try {
 
-      if (cf instanceof ActiveMQConnectionFactory && registry != null) {
-         registry.register(XARecoveryConfig.newConfig((ActiveMQConnectionFactory) cf, username, password, null));
-      }
+         Object cf = cff.createConnectionFactory();
 
-      if (qualityOfServiceMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE && !(cf instanceof XAConnectionFactory)) {
-         throw new IllegalArgumentException("Connection factory must be XAConnectionFactory");
-      }
+         if (cf instanceof ActiveMQConnectionFactory && registry != null) {
+            registry.register(XARecoveryConfig.newConfig((ActiveMQConnectionFactory) cf, username, password, null));
+         }
 
-      if (username == null) {
-         if (isXA) {
-            if (JMSBridgeImpl.trace) {
-               ActiveMQJMSBridgeLogger.LOGGER.trace("Creating an XA connection");
-            }
-            conn = ((XAConnectionFactory) cf).createXAConnection();
-         } else {
-            if (JMSBridgeImpl.trace) {
-               ActiveMQJMSBridgeLogger.LOGGER.trace("Creating a non XA connection");
-            }
-            conn = ((ConnectionFactory) cf).createConnection();
+         if (qualityOfServiceMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE && !(cf instanceof XAConnectionFactory)) {
+            throw new IllegalArgumentException("Connection factory must be XAConnectionFactory");
          }
-      } else {
-         if (isXA) {
-            if (JMSBridgeImpl.trace) {
-               ActiveMQJMSBridgeLogger.LOGGER.trace("Creating an XA connection");
+
+         if (username == null) {
+            if (isXA) {
+               if (JMSBridgeImpl.trace) {
+                  ActiveMQJMSBridgeLogger.LOGGER.trace("Creating an XA connection");
+               }
+               conn = ((XAConnectionFactory) cf).createXAConnection();
+            } else {
+               if (JMSBridgeImpl.trace) {
+                  ActiveMQJMSBridgeLogger.LOGGER.trace("Creating a non XA connection");
+               }
+               conn = ((ConnectionFactory) cf).createConnection();
             }
-            conn = ((XAConnectionFactory) cf).createXAConnection(username, password);
          } else {
-            if (JMSBridgeImpl.trace) {
-               ActiveMQJMSBridgeLogger.LOGGER.trace("Creating a non XA connection");
+            if (isXA) {
+               if (JMSBridgeImpl.trace) {
+                  ActiveMQJMSBridgeLogger.LOGGER.trace("Creating an XA connection");
+               }
+               conn = ((XAConnectionFactory) cf).createXAConnection(username, password);
+            } else {
+               if (JMSBridgeImpl.trace) {
+                  ActiveMQJMSBridgeLogger.LOGGER.trace("Creating a non XA connection");
+               }
+               conn = ((ConnectionFactory) cf).createConnection(username, password);
             }
-            conn = ((ConnectionFactory) cf).createConnection(username, password);
          }
-      }
 
-      if (clientID != null) {
-         conn.setClientID(clientID);
-      }
+         if (clientID != null) {
+            conn.setClientID(clientID);
+         }
 
-      boolean ha = false;
-      BridgeFailoverListener failoverListener = null;
+         boolean ha = false;
+         BridgeFailoverListener failoverListener = null;
 
-      if (conn instanceof ActiveMQConnection) {
-         ActiveMQConnectionFactory activeMQCF = (ActiveMQConnectionFactory) cf;
-         ha = activeMQCF.isHA();
+         if (conn instanceof ActiveMQConnection) {
+            ActiveMQConnectionFactory activeMQCF = (ActiveMQConnectionFactory) cf;
+            ha = activeMQCF.isHA();
 
-         if (ha) {
-            ActiveMQConnection activeMQConn = (ActiveMQConnection) conn;
-            failoverListener = new BridgeFailoverListener(isSource);
-            activeMQConn.setFailoverListener(failoverListener);
+            if (ha) {
+               ActiveMQConnection activeMQConn = (ActiveMQConnection) conn;
+               failoverListener = new BridgeFailoverListener(isSource);
+               activeMQConn.setFailoverListener(failoverListener);
+            }
          }
-      }
 
-      conn.setExceptionListener(new BridgeExceptionListener(ha, failoverListener, isSource));
+         conn.setExceptionListener(new BridgeExceptionListener(ha, failoverListener, isSource));
 
-      return conn;
+         return conn;
+      } catch (JMSException e) {
+         try {
+            if (conn != null) {
+               conn.close();
+            }
+         } catch (Throwable ignored) {
+         }
+         throw e;
+      }
    }
 
    /*


[2/2] activemq-artemis git commit: This closes #1809

Posted by cl...@apache.org.
This closes #1809


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

Branch: refs/heads/master
Commit: acd20790f7c7a238fd96ff3738a905b42ccda2ff
Parents: 81324e0 3658d62
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Jan 23 14:02:17 2018 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jan 23 14:02:17 2018 -0500

----------------------------------------------------------------------
 .../artemis/jms/bridge/impl/JMSBridgeImpl.java  | 97 +++++++++++---------
 1 file changed, 54 insertions(+), 43 deletions(-)
----------------------------------------------------------------------