From 5f490541f4d18db0f0e329d021953859fa61c26a Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Sat, 2 Oct 2010 22:23:55 +0000 Subject: [PATCH] Fixing a race between the session being closed and the call to commit in the async handler that caused some exceptions occasionally in the test run. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1003908 13f79535-47bb-0310-9956-ffa450edef68 --- .../broker/scheduler/JmsSchedulerTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java index 9e07060dc0..a7aac198a0 100644 --- a/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java @@ -104,7 +104,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport { latch.await(5, TimeUnit.SECONDS); assertEquals(latch.getCount(), 0); } - + public void testTransactedSchedule() throws Exception { final int COUNT = 1; Connection connection = createConnection(); @@ -116,12 +116,12 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport { final CountDownLatch latch = new CountDownLatch(COUNT); consumer.setMessageListener(new MessageListener() { public void onMessage(Message message) { - latch.countDown(); try { session.commit(); } catch (JMSException e) { e.printStackTrace(); } + latch.countDown(); } }); @@ -176,7 +176,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport { Thread.sleep(1000); assertEquals(NUMBER, count.get()); } - + public void testScheduleRestart() throws Exception { // send a message Connection connection = createConnection(); @@ -188,16 +188,16 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport { message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time); producer.send(message); producer.close(); - + //restart broker broker.stop(); broker.waitUntilStopped(); - + broker = createBroker(false); broker.start(); broker.waitUntilStarted(); - - + + // consume the message connection = createConnection(); connection.start(); @@ -217,7 +217,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport { protected BrokerService createBroker() throws Exception { return createBroker(true); } - + protected BrokerService createBroker(boolean delete) throws Exception { File schedulerDirectory = new File("target/scheduler"); if (delete) {