You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2016/09/13 16:55:04 UTC
[2/2] qpid-jms git commit: QPIDJMS-207 Fix a race condition in a
couple tests around closed state
QPIDJMS-207 Fix a race condition in a couple tests around closed state
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/dd6a44f2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/dd6a44f2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/dd6a44f2
Branch: refs/heads/master
Commit: dd6a44f2439224a90e2d47fc4199fa158162d9dc
Parents: 404e044
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Sep 13 12:54:44 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Sep 13 12:54:44 2016 -0400
----------------------------------------------------------------------
.../jms/integration/SessionIntegrationTest.java | 25 ++++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/dd6a44f2/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
index fb44710..3cc2bab 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
@@ -34,7 +34,6 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.jms.CompletionListener;
@@ -1604,12 +1603,12 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
final String BREAD_CRUMB = "ErrorMessage";
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
- final AtomicBoolean sessionClosed = new AtomicBoolean();
+ final CountDownLatch sessionClosed = new CountDownLatch(1);
JmsConnection connection = (JmsConnection) testFixture.establishConnecton(testPeer);
connection.addConnectionListener(new JmsDefaultConnectionListener() {
@Override
public void onSessionClosed(Session session, Exception exception) {
- sessionClosed.set(true);
+ sessionClosed.countDown();
}
});
@@ -1644,6 +1643,8 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
}
}, 15000, 10));
+ assertTrue("Session closed callback didn't trigger", sessionClosed.await(10, TimeUnit.SECONDS));
+
// Verify the session is now marked closed
try {
session.getAcknowledgeMode();
@@ -1654,8 +1655,6 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
assertTrue(message.contains(BREAD_CRUMB));
}
- assertTrue("Session closed callback didn't trigger", sessionClosed.get());
-
// Try closing it explicitly, should effectively no-op in client.
// The test peer will throw during close if it sends anything.
producer.close();
@@ -1707,12 +1706,12 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
final String BREAD_CRUMB = "ErrorMessage";
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
- final AtomicBoolean sessionClosed = new AtomicBoolean();
+ final CountDownLatch sessionClosed = new CountDownLatch(1);
JmsConnection connection = (JmsConnection) testFixture.establishConnecton(testPeer);
connection.addConnectionListener(new JmsDefaultConnectionListener() {
@Override
public void onSessionClosed(Session session, Exception exception) {
- sessionClosed.set(true);
+ sessionClosed.countDown();
}
});
@@ -1752,6 +1751,8 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
assertEquals(MSG_COUNT, listener.errorCount);
assertEquals(0, listener.successCount);
+ assertTrue("Session closed callback didn't trigger", sessionClosed.await(10, TimeUnit.SECONDS));
+
// Verify the session is now marked closed
try {
session.getAcknowledgeMode();
@@ -1762,8 +1763,6 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
assertTrue(errorMessage.contains(BREAD_CRUMB));
}
- assertTrue("Session closed callback didn't trigger", sessionClosed.get());
-
// Try closing it explicitly, should effectively no-op in client.
// The test peer will throw during close if it sends anything.
producer.close();
@@ -1778,12 +1777,12 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
final String BREAD_CRUMB = "ErrorMessage";
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
- final AtomicBoolean sessionClosed = new AtomicBoolean();
+ final CountDownLatch sessionClosed = new CountDownLatch(1);
JmsConnection connection = (JmsConnection) testFixture.establishConnecton(testPeer);
connection.addConnectionListener(new JmsDefaultConnectionListener() {
@Override
public void onSessionClosed(Session session, Exception exception) {
- sessionClosed.set(true);
+ sessionClosed.countDown();
}
});
@@ -1818,6 +1817,8 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
}
}, 15000, 10));
+ assertTrue("Session closed callback didn't trigger", sessionClosed.await(10, TimeUnit.SECONDS));
+
// Verify the session is now marked closed
try {
session.getAcknowledgeMode();
@@ -1828,8 +1829,6 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
assertTrue(message.contains(BREAD_CRUMB));
}
- assertTrue("Session closed callback didn't trigger", sessionClosed.get());
-
// Try closing it explicitly, should effectively no-op in client.
// The test peer will throw during close if it sends anything.
consumer.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org