You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by jbertram <gi...@git.apache.org> on 2018/01/23 15:53:40 UTC

[GitHub] activemq-artemis pull request #1809: ARTEMIS-1415 potential JMS bridge conn ...

GitHub user jbertram opened a pull request:

    https://github.com/apache/activemq-artemis/pull/1809

    ARTEMIS-1415 potential JMS bridge conn leak

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jbertram/activemq-artemis ARTEMIS-1415

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq-artemis/pull/1809.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1809
    
----
commit 591ccc717056d23d47d4e461961636d46e7d2f60
Author: Justin Bertram <jb...@...>
Date:   2018-01-23T15:40:29Z

    ARTEMIS-1415 potential JMS bridge conn leak

----


---

[GitHub] activemq-artemis issue #1809: ARTEMIS-1415 potential JMS bridge conn leak

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1809
  
    do you mind if I ammend this method as:
    
    ```java
       private Connection createConnection(final String username,
                                           final String password,
                                           final ConnectionFactoryFactory cff,
                                           final String clientID,
                                           final boolean isXA,
                                           boolean isSource) throws Exception {
          Connection conn = null;
    
          try {
    
             Object cf = cff.createConnectionFactory();
    
             if (cf instanceof ActiveMQConnectionFactory && registry != null) {
                registry.register(XARecoveryConfig.newConfig((ActiveMQConnectionFactory) cf, username, password, null));
             }
    
             if (qualityOfServiceMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE && !(cf instanceof XAConnectionFactory)) {
                throw new IllegalArgumentException("Connection factory must be XAConnectionFactory");
             }
    
             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();
                }
             } else {
                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);
                }
             }
    
             if (clientID != null) {
                conn.setClientID(clientID);
             }
    
             boolean ha = false;
             BridgeFailoverListener failoverListener = null;
    
             if (conn instanceof ActiveMQConnection) {
                ActiveMQConnectionFactory activeMQCF = (ActiveMQConnectionFactory) cf;
                ha = activeMQCF.isHA();
    
                if (ha) {
                   ActiveMQConnection activeMQConn = (ActiveMQConnection) conn;
                   failoverListener = new BridgeFailoverListener(isSource);
                   activeMQConn.setFailoverListener(failoverListener);
                }
             }
    
             conn.setExceptionListener(new BridgeExceptionListener(ha, failoverListener, isSource));
    
             return conn;
          } catch (JMSException e) {
             try {
                if (conn != null) {
                   conn.close();
                }
             } catch (Throwable ignored) {
             }
             throw e;
          }
       }
    ```


---

[GitHub] activemq-artemis issue #1809: ARTEMIS-1415 potential JMS bridge conn leak

Posted by jbertram <gi...@git.apache.org>.
Github user jbertram commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1809
  
    @clebertsuconic, go for it.


---

[GitHub] activemq-artemis issue #1809: ARTEMIS-1415 potential JMS bridge conn leak

Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1809
  
    @jbertram just playing safe! :)


---

[GitHub] activemq-artemis pull request #1809: ARTEMIS-1415 potential JMS bridge conn ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/activemq-artemis/pull/1809


---