[jboss-cvs] JBoss Messaging SVN: r7639 - in trunk: tests/jms-tests/src/org/jboss/test/messaging/jms and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 29 10:21:41 EDT 2009
Author: jmesnil
Date: 2009-07-29 10:21:41 -0400 (Wed, 29 Jul 2009)
New Revision: 7639
Modified:
trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
Log:
JBMESSAGING-1566: Temporary Destinations should not allow their consumers to be created on other connections than their own as per JMS spec
* when creating a consumer in JBossSession, check that the connection contains the temporary destination's address to ensure it was indeed created by the current connection
* added tests in TemporaryDestinationTest
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java 2009-07-29 10:37:54 UTC (rev 7638)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java 2009-07-29 14:21:41 UTC (rev 7639)
@@ -385,15 +385,20 @@
// Public ---------------------------------------------------------------------------------------
- public void addTemporaryQueue(final SimpleString queueName)
+ public void addTemporaryQueue(final SimpleString queueAddress)
{
- tempQueues.add(queueName);
+ tempQueues.add(queueAddress);
}
- public void removeTemporaryQueue(final SimpleString queueName)
+ public void removeTemporaryQueue(final SimpleString queueAddress)
{
- tempQueues.remove(queueName);
+ tempQueues.remove(queueAddress);
}
+
+ public boolean containsTemporaryQueue(final SimpleString queueAddress)
+ {
+ return tempQueues.contains(queueAddress);
+ }
public boolean hasNoLocal()
{
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java 2009-07-29 10:37:54 UTC (rev 7638)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java 2009-07-29 14:21:41 UTC (rev 7639)
@@ -390,6 +390,11 @@
JBossDestination jbdest = (JBossDestination)destination;
+ if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress()))
+ {
+ throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection");
+ }
+
JBossMessageConsumer consumer = createConsumer(jbdest, null, messageSelector, noLocal);
return consumer;
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java 2009-07-29 10:37:54 UTC (rev 7638)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java 2009-07-29 14:21:41 UTC (rev 7639)
@@ -473,7 +473,62 @@
}
}
+ /**
+ * https://jira.jboss.org/jira/browse/JBMESSAGING-1566
+ */
+ public void testCanNotCreateConsumerFromAnotherConnectionForTemporaryQueue() throws Exception
+ {
+ Connection conn = cf.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ TemporaryQueue tempQueue = sess.createTemporaryQueue();
+
+ Connection anotherConn = cf.createConnection();
+
+ Session sessFromAnotherConn = anotherConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ try
+ {
+ sessFromAnotherConn.createConsumer(tempQueue);
+ fail("Only temporary destination's own connection is allowed to create MessageConsumers for them.");
+ }
+ catch (JMSException e)
+ {
+ }
+
+ conn.close();
+ anotherConn.close();
+ }
+
+ /**
+ * https://jira.jboss.org/jira/browse/JBMESSAGING-1566
+ */
+ public void testCanNotCreateConsumerFromAnotherCnnectionForTemporaryTopic() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ TemporaryTopic tempTopic = sess.createTemporaryTopic();
+
+ Connection anotherConn = cf.createConnection();
+
+ Session sessFromAnotherConn = anotherConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ try
+ {
+ sessFromAnotherConn.createConsumer(tempTopic);
+ fail("Only temporary destination's own connection is allowed to create MessageConsumers for them.");
+ }
+ catch (JMSException e)
+ {
+ }
+
+ conn.close();
+ anotherConn.close();
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list