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 061C31063F for ; Thu, 18 Dec 2014 02:41:32 +0000 (UTC) Received: (qmail 21962 invoked by uid 500); 18 Dec 2014 02:41:31 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 21807 invoked by uid 500); 18 Dec 2014 02:41:31 -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 21592 invoked by uid 99); 18 Dec 2014 02:41:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Dec 2014 02:41:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 87A8A8C4C80; Thu, 18 Dec 2014 02:41:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hadrian@apache.org To: commits@activemq.apache.org Date: Thu, 18 Dec 2014 02:41:34 -0000 Message-Id: <5b53e7f0261f4aafa9ba0c6f2d358405@git.apache.org> In-Reply-To: <6214e79401394325b4e0f3f8937b3721@git.apache.org> References: <6214e79401394325b4e0f3f8937b3721@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [04/17] activemq git commit: Add try/catch blocks to prevent client shutdown errors from preventing Broker shutdown. Add try/catch blocks to prevent client shutdown errors from preventing Broker shutdown. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/f436b334 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/f436b334 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/f436b334 Branch: refs/heads/activemq-5.10.x Commit: f436b3344f92e65bc633e770a2dcfdd90b7e8971 Parents: b66daf2 Author: Timothy Bish Authored: Fri Aug 8 12:34:38 2014 -0400 Committer: Hadrian Zbarcea Committed: Wed Dec 17 19:27:07 2014 -0500 ---------------------------------------------------------------------- .../activemq/JmsTransactionTestSupport.java | 60 ++++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/f436b334/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java ---------------------------------------------------------------------- diff --git a/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java b/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java index 013ecff..7f212cd 100755 --- a/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java +++ b/activemq-broker/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java @@ -41,7 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * */ public abstract class JmsTransactionTestSupport extends TestSupport implements MessageListener { @@ -61,8 +61,8 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M protected BrokerService broker; // for message listener test - private List unackMessages = new ArrayList(MESSAGE_COUNT); - private List ackMessages = new ArrayList(MESSAGE_COUNT); + private final List unackMessages = new ArrayList(MESSAGE_COUNT); + private final List ackMessages = new ArrayList(MESSAGE_COUNT); private boolean resendPhase; public JmsTransactionTestSupport() { @@ -75,9 +75,10 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { broker = createBroker(); broker.start(); @@ -119,19 +120,29 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { LOG.info("Closing down connection"); - session.close(); - session = null; - connection.close(); - connection = null; - broker.stop(); - broker.waitUntilStopped(); - broker = null; + try { + session.close(); + session = null; + connection.close(); + connection = null; + } catch (Exception e) { + LOG.info("Caught exception while closing resources."); + } + + try { + broker.stop(); + broker.waitUntilStopped(); + broker = null; + } catch (Exception e) { + LOG.info("Caught exception while shutting down the Broker", e); + } LOG.info("Connection closed."); } @@ -140,7 +151,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the messages are received. - * + * * @throws Exception */ public void testSendReceiveTransactedBatches() throws Exception { @@ -174,7 +185,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the rollbacked message was * not consumed. - * + * * @throws Exception */ public void testSendRollback() throws Exception { @@ -295,7 +306,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the message sent before * session close is not consumed. - * + * * @throws Exception */ public void testSendSessionAndConnectionClose() throws Exception { @@ -343,7 +354,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the rollbacked message was * redelivered. - * + * * @throws Exception */ public void testReceiveRollback() throws Exception { @@ -394,7 +405,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the rollbacked message was * redelivered. - * + * * @throws Exception */ public void testReceiveTwoThenRollback() throws Exception { @@ -448,7 +459,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the rollbacked message was * not consumed. - * + * * @throws Exception */ public void testSendReceiveWithPrefetchOne() throws Exception { @@ -479,7 +490,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Perform the test that validates if the rollbacked message was redelivered * multiple times. - * + * * @throws Exception */ public void testReceiveTwoThenRollbackManyTimes() throws Exception { @@ -491,7 +502,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Sends a batch of messages and validates that the rollbacked message was * not consumed. This test differs by setting the message prefetch to one. - * + * * @throws Exception */ public void testSendRollbackWithPrefetchOfOne() throws Exception { @@ -503,7 +514,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M * Sends a batch of messages and and validates that the rollbacked message * was redelivered. This test differs by setting the message prefetch to * one. - * + * * @throws Exception */ public void testReceiveRollbackWithPrefetchOfOne() throws Exception { @@ -514,7 +525,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Tests if the messages can still be received if the consumer is closed * (session is not closed). - * + * * @throws Exception see http://jira.codehaus.org/browse/AMQ-143 */ public void testCloseConsumerBeforeCommit() throws Exception { @@ -605,7 +616,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Recreates the connection. - * + * * @throws JMSException */ protected void reconnect() throws Exception { @@ -622,7 +633,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M /** * Recreates the connection. - * + * * @throws JMSException */ protected void reconnectSession() throws JMSException { @@ -671,6 +682,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M reconnect(); } + @Override public void onMessage(Message message) { if (!resendPhase) { unackMessages.add(message);