[hornetq-commits] JBoss hornetq SVN: r8904 - in trunk: tests/jms-tests/src/org/hornetq/jms/tests and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Feb 26 12:32:57 EST 2010


Author: jmesnil
Date: 2010-02-26 12:32:57 -0500 (Fri, 26 Feb 2010)
New Revision: 8904

Modified:
   trunk/src/main/org/hornetq/jms/client/HornetQMessageConsumer.java
   trunk/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java
Log:
fixed closed consumer

* checkClosed() must throw a JMS illegal state exception even when only
  the consumer has been closed (and not the session or connection)
* add fail() calls to MessageConsumerTest to check methods can not be called on a closed consumer

Modified: trunk/src/main/org/hornetq/jms/client/HornetQMessageConsumer.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQMessageConsumer.java	2010-02-26 14:40:18 UTC (rev 8903)
+++ trunk/src/main/org/hornetq/jms/client/HornetQMessageConsumer.java	2010-02-26 17:32:57 UTC (rev 8904)
@@ -64,6 +64,8 @@
    private final String selector;
 
    private final SimpleString autoDeleteQueueName;
+   
+   private boolean closed = false;
 
    // Constructors --------------------------------------------------
 
@@ -154,12 +156,18 @@
       {
          throw JMSExceptionHelper.convertFromHornetQException(e);
       }
+      finally
+      {
+         closed = true;
+      }
    }
 
    // QueueReceiver implementation ----------------------------------
 
    public Queue getQueue() throws JMSException
    {
+      checkClosed();
+
       return (Queue)destination;
    }
 
@@ -167,6 +175,8 @@
 
    public Topic getTopic() throws JMSException
    {
+      checkClosed();
+
       return (Topic)destination;
    }
 
@@ -191,7 +201,7 @@
 
    private void checkClosed() throws JMSException
    {
-      if (session.getCoreSession().isClosed())
+      if (closed || session.getCoreSession().isClosed())
       {
          throw new IllegalStateException("Consumer is closed");
       }

Modified: trunk/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java	2010-02-26 14:40:18 UTC (rev 8903)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/MessageConsumerTest.java	2010-02-26 17:32:57 UTC (rev 8904)
@@ -1572,6 +1572,7 @@
          try
          {
             topicConsumer.getMessageSelector();
+            fail("must throw a JMS IllegalStateException");
          }
          catch (javax.jms.IllegalStateException e)
          {
@@ -1629,6 +1630,7 @@
          try
          {
             ((TopicSubscriber)topicConsumer).getTopic();
+            fail("must throw a JMS IllegalStateException");
          }
          catch (javax.jms.IllegalStateException e)
          {
@@ -1686,6 +1688,7 @@
          try
          {
             ((QueueReceiver)queueConsumer).getQueue();
+            fail("must throw a JMS IllegalStateException");
          }
          catch (javax.jms.IllegalStateException e)
          {



More information about the hornetq-commits mailing list