[jboss-cvs] JBossAS SVN: r63350 - branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jms.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 5 10:44:45 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-06-05 10:44:44 -0400 (Tue, 05 Jun 2007)
New Revision: 63350

Modified:
   branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java
Log:
JBCTS-588, throw InvalidDestinationException if the wrong session type is accessed.
Don't cast the session to a TopicSession in createDurableSubscriber(Topic, String).

Modified: branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java	2007-06-05 14:09:19 UTC (rev 63349)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java	2007-06-05 14:44:44 UTC (rev 63350)
@@ -28,6 +28,7 @@
 import javax.jms.BytesMessage;
 import javax.jms.Destination;
 import javax.jms.IllegalStateException;
+import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
 import javax.jms.MessageListener;
 import javax.jms.MapMessage;
@@ -318,7 +319,7 @@
          throw new IllegalStateException("Cannot create durable subscriber from javax.jms.QueueSession");         
       }
       
-      TopicSession session = getTopicSession();
+      Session session = getSession();
       if (trace)
          log.trace("createDurableSubscriber " + session + " topic=" + topic + " name=" + name);
       TopicSubscriber result = session.createDurableSubscriber(topic, name);
@@ -671,11 +672,17 @@
    
    QueueSession getQueueSession() throws JMSException
    {
-      return (QueueSession) getSession();
+      Session s = getSession();
+      if( !(s instanceof QueueSession) )
+         throw new InvalidDestinationException("Attempting to use QueueSession methods on: "+this);
+      return (QueueSession) s; 
    }
    
    TopicSession getTopicSession() throws JMSException
    {
-      return (TopicSession) getSession();
+      Session s = getSession();
+      if( !(s instanceof TopicSession) )
+         throw new InvalidDestinationException("Attempting to use TopicSession methods on: "+this);
+      return (TopicSession) s; 
    }
 }




More information about the jboss-cvs-commits mailing list