activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1211835 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/ apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/ ap...
Date Thu, 08 Dec 2011 11:21:59 GMT
Author: chirino
Date: Thu Dec  8 11:21:58 2011
New Revision: 1211835

URL: http://svn.apache.org/viewvc?rev=1211835&view=rev
Log:
Fixes APLO-104: Internal Server Error log message does not provide enough information

Also allow destination names to include a space.

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
    activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala?rev=1211835&r1=1211834&r2=1211835&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala
Thu Dec  8 11:21:58 2011
@@ -1025,14 +1025,21 @@ class LocalRouter(val virtual_host:Virtu
   }
 
   def bind(destination: Array[DestinationDTO], consumer: DeliveryConsumer, security: SecurityContext)
= {
-    if(!virtual_host.service_state.is_started) {
-      Some("virtual host stopped.")
-    } else {
-      consumer.retain
-      val paths = destination.map(x=> (destination_parser.decode_path(x.path), x) )
-      dispatch_queue ! {
+    consumer.retain
+    dispatch_queue ! {
+      var rc:Option[String] = None
+      val paths = try {
+        destination.map(x => (destination_parser.decode_path(x.path), x))
+      } catch {
+        case x:PathException =>
+          rc = Some(x.getMessage)
+          null
+      }
+      if(rc.isEmpty && !virtual_host.service_state.is_started) {
+        rc = Some("virtual host stopped.")
+      } else if (rc.isEmpty) {
         val failures = paths.flatMap(x=> domain(x._2).can_bind_all(x._1, x._2, consumer,
security) )
-        val rc = if( !failures.isEmpty ) {
+        rc = if( !failures.isEmpty ) {
           Some(failures.mkString("; "))
         } else {
           paths.foreach { x=>
@@ -1040,9 +1047,9 @@ class LocalRouter(val virtual_host:Virtu
           }
           None
         }
-        consumer.release
-        rc
       }
+      consumer.release
+      rc
     }
   }
 
@@ -1057,16 +1064,22 @@ class LocalRouter(val virtual_host:Virtu
   }
 
   def connect(destinations: Array[DestinationDTO], producer: BindableDeliveryProducer, security:
SecurityContext) = {
-    if(!virtual_host.service_state.is_started) {
-      Some("virtual host stopped.")
-    } else {
-      producer.retain
-      val paths = destinations.map(x=> (destination_parser.decode_path(x.path), x) )
-      dispatch_queue ! {
-
+    producer.retain
+    dispatch_queue ! {
+      var rc:Option[String] = None
+      val paths = try {
+        destinations.map(x=> (destination_parser.decode_path(x.path), x) )
+      } catch {
+        case x:PathException =>
+          rc = Some(x.getMessage)
+          null
+      }
+      if(rc.isEmpty && !virtual_host.service_state.is_started) {
+        rc = Some("virtual host stopped.")
+      } else if(rc.isEmpty) {
+        val paths = destinations.map(x=> (destination_parser.decode_path(x.path), x) )
         val failures = paths.flatMap(x=> domain(x._2).can_connect_all(x._1, x._2, producer,
security) )
-        if( !failures.isEmpty ) {
-          producer.release
+        rc = if( !failures.isEmpty ) {
           Some(failures.mkString("; "))
         } else {
           paths.foreach { x=>
@@ -1076,6 +1089,10 @@ class LocalRouter(val virtual_host:Virtu
           None
         }
       }
+      if(rc.isDefined) {
+        producer.release
+      }
+      rc
     }
   }
 

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=1211835&r1=1211834&r2=1211835&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 11:21:58 2011
@@ -510,7 +510,7 @@ class StompProtocolHandler extends Proto
   implicit def toDestinationDTO(value:AsciiBuffer):Array[DestinationDTO] = {
     val rc = destination_parser.decode_destination(value.toString)
     if( rc==null ) {
-      throw new ProtocolException("Invalid stomp destiantion name: "+value);
+      throw new ProtocolException("Invalid stomp destination name: "+value);
     }
     rc.map { dest =>
       if( dest.temp() ) {
@@ -585,7 +585,7 @@ class StompProtocolHandler extends Proto
   class Break extends RuntimeException
 
   private def async_die(msg:String, e:Throwable=null) = try {
-    die(msg)
+    die(msg, e)
   } catch {
     case x:Break=>
   }
@@ -598,7 +598,7 @@ class StompProtocolHandler extends Proto
 
   private def die[T](msg:String, e:Throwable=null):T = {
     if( e!=null) {
-      connection_log.info(e, "STOMP connection '%s' error: %s", security_context.remote_address,
msg)
+      connection_log.info(e, "STOMP connection '%s' error: %s", security_context.remote_address,
msg, e)
     } else {
       connection_log.info("STOMP connection '%s' error: %s", security_context.remote_address,
msg)
     }
@@ -721,22 +721,23 @@ class StompProtocolHandler extends Proto
                 }
 
               case _ =>
-                die("Invalid frame: "+frame.action);
+                die("Invalid STOMP frame command: "+frame.action);
             }
           }
 
         case _=>
-          die("Internal Server Error: unexpected command type");
+          die("Internal Server Error: unexpected stomp type");
       }
     }  catch {
       case e: Break =>
       case e:Exception =>
         // To avoid double logging to the same log category..
+        var msg: String = "Internal Server Error: " + e
         if( connection_log!=StompProtocolHandler ) {
           // but we also want the error on the apollo.log file.
-          warn(e, "Internal Server Error")
+          warn(e, msg)
         }
-        async_die("Internal Server Error", e);
+        async_die(msg, e);
     }
   }
 

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala?rev=1211835&r1=1211834&r2=1211835&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathParser.scala
Thu Dec  8 11:21:58 2011
@@ -117,7 +117,7 @@ class PathParser {
   var regex_wildcard_start = "{"
   var regex_wildcard_end = "}"
   var path_separator = "."
-  var part_pattern = Pattern.compile("[a-zA-Z0-9\\_\\-\\%\\~]+")
+  var part_pattern = Pattern.compile("[ a-zA-Z0-9\\_\\-\\%\\~]+")
 
   def copy(other:PathParser) = {
     any_descendant_wildcard = other.any_descendant_wildcard

Modified: activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md?rev=1211835&r1=1211834&r2=1211835&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md (original)
+++ activemq/activemq-apollo/trunk/apollo-website/src/documentation/user-manual.md Thu Dec
 8 11:21:58 2011
@@ -1635,6 +1635,6 @@ header in the STOMP `SUBSCRIBE` frame to
 ### Destination Name Restrictions
 
 Destination names are restricted to using the characters `a-z`, `A-Z`, `0-9`,
-`_`, `-` `%`, `~`, or `.` in addition to composite separator `,` and the wild
+`_`, `-` `%`, `~`, ' ', or `.` in addition to composite separator `,` and the wild
 card `*`.
 



Mime
View raw message