activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1420982 - in /activemq/activemq-apollo/trunk: apollo-amqp/src/test/scala/org/apache/activemq/apollo/amqp/test/ apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/ apollo-openwire/src/main/scala/org/apache/activemq/apollo/op...
Date Wed, 12 Dec 2012 21:33:28 GMT
Author: chirino
Date: Wed Dec 12 21:33:26 2012
New Revision: 1420982

URL: http://svn.apache.org/viewvc?rev=1420982&view=rev
Log:
Return the right type of exception to the openwire clients when they try to unsubscribe with
an invalid sub name.

Added:
    activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireException.java
Modified:
    activemq/activemq-apollo/trunk/apollo-amqp/src/test/scala/org/apache/activemq/apollo/amqp/test/QpidJmsTest.scala
    activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/codec/BaseDataStreamMarshaller.java

Modified: activemq/activemq-apollo/trunk/apollo-amqp/src/test/scala/org/apache/activemq/apollo/amqp/test/QpidJmsTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-amqp/src/test/scala/org/apache/activemq/apollo/amqp/test/QpidJmsTest.scala?rev=1420982&r1=1420981&r2=1420982&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-amqp/src/test/scala/org/apache/activemq/apollo/amqp/test/QpidJmsTest.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-amqp/src/test/scala/org/apache/activemq/apollo/amqp/test/QpidJmsTest.scala
Wed Dec 12 21:33:26 2012
@@ -65,24 +65,31 @@ class QpidJmsTest extends AmqpTestSuppor
     return connection
   }
 
+  test("unsubscribe invalid dest") {
+    val queue = new QueueImpl("queue://txqueue")
+    val connection = createConnection
+    val session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
+    session.unsubscribe("does not exist")
+    connection.close
+  }
 
-//  test("browse") {
-//    val queue = new QueueImpl("queue://txqueue")
-//    val connection = createConnection
-//    val session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
-//    val p = session.createProducer(queue)
-//    val msg = session.createTextMessage("Hello World")
-//    msg.setObjectProperty("x", 1)
-//    p.send(msg)
-//    val browser = session.createBrowser(queue)
-//    val enumeration = browser.getEnumeration
-//    while (enumeration.hasMoreElements) {
-//      System.out.println("BROWSE " + enumeration.nextElement)
-//    }
-//    connection.close
-//  }
+  ignore("browse") {
+    val queue = new QueueImpl("queue://txqueue")
+    val connection = createConnection
+    val session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
+    val p = session.createProducer(queue)
+    val msg = session.createTextMessage("Hello World")
+    msg.setObjectProperty("x", 1)
+    p.send(msg)
+    val browser = session.createBrowser(queue)
+    val enumeration = browser.getEnumeration
+    while (enumeration.hasMoreElements) {
+      System.out.println("BROWSE " + enumeration.nextElement)
+    }
+    connection.close
+  }
 
-  test("Send Nack Receive") {
+  ignore("Send Nack Receive") {
     // enableJMSFrameTracing
     val queue = new QueueImpl("/queue/testqueue")
     val nMsgs = 1

Added: activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireException.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireException.java?rev=1420982&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireException.java
(added)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireException.java
Wed Dec 12 21:33:26 2012
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.apollo.openwire;
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class OpenwireException extends RuntimeException {
+
+    private final String className;
+
+    public OpenwireException(String s, String className) {
+        super(s);
+        this.className = className;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+}

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala?rev=1420982&r1=1420981&r2=1420982&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
Wed Dec 12 21:33:26 2012
@@ -317,11 +317,13 @@ class OpenwireProtocolHandler extends Pr
   class ProtocolException(msg:String) extends RuntimeException(msg)
   class Break extends RuntimeException
 
-  def fail[T](msg: String, actual:Command=null):Unit = {
+  def fail[T](msg: String):Unit = fail(msg, null)
+  def fail[T](msg: String, actual:Command):Unit = fail(new ProtocolException(msg), actual)
+
+  def fail[T](e: Throwable, actual:Command):Unit = {
+    e.fillInStackTrace()
     def respond(command:Command) = {
       if(command.isResponseRequired()) {
-        val e = new ProtocolException(msg)
-        e.fillInStackTrace
 
         val rc = new ExceptionResponse()
         rc.setCorrelationId(command.getCommandId())
@@ -332,12 +334,8 @@ class OpenwireProtocolHandler extends Pr
       }
     }
     def connection_error() = {
-      val e = new ProtocolException(msg)
-      e.fillInStackTrace()
-
       val err = new ConnectionError()
       err.setException(e)
-
       connection_session.offer(err)
     }
     (current_command,actual) match {
@@ -347,7 +345,7 @@ class OpenwireProtocolHandler extends Pr
          respond(command)
        case (command:Command, null)=>
          connection_error()
-       case (command:Command, command2:Command)=>
+       case (command2:Command, command:Command)=>
          respond(command)
     }
   }
@@ -520,7 +518,7 @@ class OpenwireProtocolHandler extends Pr
     host.dispatch_queue {
       host.local_router.dsub_domain.destination_by_id.get(subscription_id) match {
         case None =>
-          queue(fail("The subscription does not exist", info))
+          queue(fail(new OpenwireException("The subscription does not exist", "javax.jms.InvalidDestinationException"),
info))
         case Some(dest:Queue) =>
           host.local_router._destroy_queue(dest, security_context) match {
             case Some(error) =>

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/codec/BaseDataStreamMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/codec/BaseDataStreamMarshaller.java?rev=1420982&r1=1420981&r2=1420982&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/codec/BaseDataStreamMarshaller.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/codec/BaseDataStreamMarshaller.java
Wed Dec 12 21:33:26 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.apollo.openwire.codec;
 
+import org.apache.activemq.apollo.openwire.OpenwireException;
 import org.apache.activemq.apollo.openwire.command.DataStructure;
 import org.fusesource.hawtbuf.Buffer;
 import org.fusesource.hawtbuf.DataByteArrayInputStream;
@@ -229,7 +230,7 @@ public abstract class BaseDataStreamMars
             Constructor constructor = clazz.getConstructor(new Class[] {UTF8Buffer.class});
             return (Throwable)constructor.newInstance(new Object[] {message.toString()});
         } catch (Throwable e) {
-            return new Throwable(className + ": " + message);
+            return new OpenwireException(message.toString(), className.toString());
         }
     }
 
@@ -241,7 +242,8 @@ public abstract class BaseDataStreamMars
         } else {
             int rc = 0;
             bs.writeBoolean(true);
-            rc += tightMarshalString1(new UTF8Buffer(o.getClass().getName()), bs);
+            String className = o instanceof OpenwireException ? ((OpenwireException)o).getClassName()
: o.getClass().getName();
+            rc += tightMarshalString1(new UTF8Buffer(className), bs);
             rc += tightMarshalString1(new UTF8Buffer(o.getMessage()), bs);
             if (wireFormat.isStackTraceEnabled()) {
                 rc += 2;
@@ -262,7 +264,8 @@ public abstract class BaseDataStreamMars
     protected void tightMarshalThrowable2(OpenWireFormat wireFormat, Throwable o, DataByteArrayOutputStream
dataOut,
                                           BooleanStream bs) throws IOException {
         if (bs.readBoolean()) {
-            tightMarshalString2(new UTF8Buffer(o.getClass().getName()), dataOut, bs);
+            String className = o instanceof OpenwireException ? ((OpenwireException)o).getClassName()
: o.getClass().getName();
+            tightMarshalString2(new UTF8Buffer(className), dataOut, bs);
             tightMarshalString2(new UTF8Buffer(o.getMessage()), dataOut, bs);
             if (wireFormat.isStackTraceEnabled()) {
                 StackTraceElement[] stackTrace = o.getStackTrace();
@@ -529,7 +532,8 @@ public abstract class BaseDataStreamMars
         throws IOException {
         dataOut.writeBoolean(o != null);
         if (o != null) {
-            looseMarshalString(new UTF8Buffer(o.getClass().getName()), dataOut);
+            String className = o instanceof OpenwireException ? ((OpenwireException)o).getClassName()
: o.getClass().getName();
+            looseMarshalString(new UTF8Buffer(className), dataOut);
             looseMarshalString(new UTF8Buffer(o.getMessage()), dataOut);
             if (wireFormat.isStackTraceEnabled()) {
                 StackTraceElement[] stackTrace = o.getStackTrace();



Mime
View raw message