You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/12/08 14:44:49 UTC

svn commit: r1211884 - in /activemq/activemq-apollo/trunk/apollo-stomp/src: main/scala/org/apache/activemq/apollo/stomp/ test/scala/org/apache/activemq/apollo/stomp/

Author: chirino
Date: Thu Dec  8 13:44:49 2011
New Revision: 1211884

URL: http://svn.apache.org/viewvc?rev=1211884&view=rev
Log:
Fixes APLO-106: Odd reply-to headers do not cause errors

Modified:
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompFrame.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompFrame.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompFrame.scala?rev=1211884&r1=1211883&r2=1211884&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompFrame.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompFrame.scala Thu Dec  8 13:44:49 2011
@@ -434,6 +434,8 @@ object Stomp {
 
   val TEXT_PLAIN = ascii("text/plain")
 
+  val TEMP_QUEUE = ascii("/temp-queue/")
+  val TEMP_TOPIC = ascii("/temp-topic/")
 
   //	public enum Transformations {
   //		JMS_BYTE, JMS_OBJECT_XML, JMS_OBJECT_JSON, JMS_MAP_XML, JMS_MAP_JSON

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1211884&r1=1211883&r2=1211884&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala Thu Dec  8 13:44:49 2011
@@ -971,9 +971,16 @@ class StompProtocolHandler extends Proto
       rc ::= (DESTINATION -> encode_header(destination_parser.encode_destination(destination)))
     }
     get(headers, REPLY_TO).foreach { value=>
-      val dests:Array[DestinationDTO] = value
-      if( dests.find(_.temp()).isDefined ) {
-        rc ::= (REPLY_TO -> encode_header(destination_parser.encode_destination(dests)))
+      // we may need to translate local temp destination names to broker destination names
+      if( value.indexOf(TEMP_QUEUE)>=0 || value.indexOf(TEMP_TOPIC)>=0 ) {
+        try {
+          val dests: Array[DestinationDTO] = value
+          if (dests.find(_.temp()).isDefined) {
+            rc ::= (REPLY_TO -> encode_header(destination_parser.encode_destination(dests)))
+          }
+        } catch {
+          case _=> // the translation is a best effort thing.
+        }
       }
     }
 

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala?rev=1211884&r1=1211883&r2=1211884&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala Thu Dec  8 13:44:49 2011
@@ -1935,4 +1935,27 @@ class StompTempDestinationTest extends S
 
   }
 
+
+  test("Odd reply-to headers do not cause errors") {
+    connect("1.1")
+
+    client.write(
+      "SEND\n" +
+      "destination:/queue/oddrepyto\n" +
+      "reply-to:sms:8139993334444\n" +
+      "receipt:0\n" +
+      "\n")
+    wait_for_receipt("0")
+
+    client.write(
+      "SUBSCRIBE\n" +
+      "destination:/queue/oddrepyto\n" +
+      "id:1\n" +
+      "\n")
+
+    val frame = client.receive()
+    frame should startWith("MESSAGE\n")
+    frame should include("reply-to:sms:8139993334444\n")
+  }
+
 }
\ No newline at end of file