diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2012-02-27 23:43:02 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2012-02-27 23:43:02 +0000 |
commit | 18be2f3e3967c95e62d6f1308368fc5a669effec (patch) | |
tree | 53da1779a4f8581c0fb93ba72c37cf4f6e1ffccf | |
parent | f80d421edf6a3775b563cba41aaaa4d1d258bdf3 (diff) | |
download | qpid-python-18be2f3e3967c95e62d6f1308368fc5a669effec.tar.gz |
QPID-2621 : [Java Client] Calling QueueBrowser.getEnumeration on a stopped connection will hang
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1294397 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java | 4 | ||||
-rw-r--r-- | qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java index bd83e8b37b..0c6031ea91 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueBrowser.java @@ -132,6 +132,10 @@ public class AMQQueueBrowser implements QueueBrowser public Enumeration getEnumeration() throws JMSException { checkState(); + if(!_session.getAMQConnection().started()) + { + throw new IllegalStateException("Cannot enumerate message on the queue while the Connection is stopped"); + } final BasicMessageConsumer consumer = (BasicMessageConsumer) _session.createBrowserConsumer(_queue, _messageSelector, false); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java index f3433adb3f..6b6b4a7b3c 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java @@ -420,4 +420,21 @@ public class QueueBrowserAutoAckTest extends QpidBrokerTestCase validate(messages); } + public void testBrowsingWhileStopped() throws JMSException + { + _clientConnection.stop(); + + try + { + QueueBrowser browser = _clientSession.createBrowser(getTestQueue()); + Enumeration messages = browser.getEnumeration(); + fail("Expected exception when attempting to browse on a stopped connection did not occur"); + } + catch(javax.jms.IllegalStateException e) + { + // pass + } + + } + } |