Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A6D567063 for ; Wed, 17 Aug 2011 13:29:57 +0000 (UTC) Received: (qmail 95806 invoked by uid 500); 17 Aug 2011 13:29:57 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 95740 invoked by uid 500); 17 Aug 2011 13:29:56 -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 95733 invoked by uid 99); 17 Aug 2011 13:29:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 13:29:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 13:29:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F25A623889B1 for ; Wed, 17 Aug 2011 13:29:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1158694 - in /activemq/trunk/activemq-pool/src: main/java/org/apache/activemq/pool/ test/java/org/apache/activemq/pool/ Date: Wed, 17 Aug 2011 13:29:35 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110817132935.F25A623889B1@eris.apache.org> Author: tabish Date: Wed Aug 17 13:29:35 2011 New Revision: 1158694 URL: http://svn.apache.org/viewvc?rev=1158694&view=rev Log: Apply patch for: https://issues.apache.org/jira/browse/AMQ-3457 Modified: activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java Modified: activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java?rev=1158694&r1=1158693&r2=1158694&view=diff ============================================================================== --- activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java (original) +++ activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/ConnectionPool.java Wed Aug 17 13:29:35 2011 @@ -144,6 +144,12 @@ public class ConnectionPool { lastUsed = System.currentTimeMillis(); if (referenceCount == 0) { expiredCheck(); + + // only clean up temp destinations when all users + // of this connection have called close + if (getConnection() != null) { + getConnection().cleanUpTempDestinations(); + } } } Modified: activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java?rev=1158694&r1=1158693&r2=1158694&view=diff ============================================================================== --- activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java (original) +++ activemq/trunk/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnection.java Wed Aug 17 13:29:35 2011 @@ -16,9 +16,6 @@ */ package org.apache.activemq.pool; -import java.util.Iterator; -import java.util.concurrent.ConcurrentHashMap; - import javax.jms.Connection; import javax.jms.ConnectionConsumer; import javax.jms.ConnectionMetaData; @@ -39,7 +36,6 @@ import org.apache.activemq.ActiveMQSessi import org.apache.activemq.AlreadyClosedException; import org.apache.activemq.EnhancedConnection; import org.apache.activemq.advisory.DestinationSource; -import org.apache.activemq.command.ActiveMQTempDestination; /** * Represents a proxy {@link Connection} which is-a {@link TopicConnection} and @@ -73,9 +69,6 @@ public class PooledConnection implements public void close() throws JMSException { if (this.pool != null) { this.pool.decrementReferenceCount(); - if (this.pool.getConnection() != null) { - this.pool.getConnection().cleanUpTempDestinations(); - } this.pool = null; } } Modified: activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java?rev=1158694&r1=1158693&r2=1158694&view=diff ============================================================================== --- activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java (original) +++ activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryWithTemporaryDestinationsTest.java Wed Aug 17 13:29:35 2011 @@ -53,6 +53,36 @@ public class PooledConnectionFactoryWith broker.stop(); } + public void testTemporaryQueueWithMultipleConnectionUsers() throws Exception { + Connection pooledConnection = null; + Connection pooledConnection2 = null; + Session session = null; + Session session2 = null; + Queue tempQueue = null; + Queue normalQueue = null; + + pooledConnection = pooledFactory.createConnection(); + session = pooledConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); + tempQueue = session.createTemporaryQueue(); + LOG.info("Created queue named: " + tempQueue.getQueueName()); + + assertEquals(1, countBrokerTemporaryQueues()); + + pooledConnection2 = pooledFactory.createConnection(); + session2 = pooledConnection2.createSession(false, Session.AUTO_ACKNOWLEDGE); + normalQueue = session2.createQueue("queue:FOO.TEST"); + LOG.info("Created queue named: " + normalQueue.getQueueName()); + + // didn't create a temp queue on pooledConnection2 so we should still have a temp queue + pooledConnection2.close(); + assertEquals(1, countBrokerTemporaryQueues()); + + // after closing pooledConnection, where we created the temp queue, there should + // be no temp queues left + pooledConnection.close(); + assertEquals(0, countBrokerTemporaryQueues()); + } + public void testTemporaryQueueLeakAfterConnectionClose() throws Exception { Connection pooledConnection = null; Session session = null;