activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1378607 - in /activemq/activemq-apollo/trunk: apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
Date Wed, 29 Aug 2012 15:27:49 GMT
Author: chirino
Date: Wed Aug 29 15:27:49 2012
New Revision: 1378607

URL: http://svn.apache.org/viewvc?rev=1378607&view=rev
Log:
Fixes APLO-255: Typo and weird exception text in StompCodec.scala

Modified:
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala?rev=1378607&r1=1378606&r2=1378607&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompCodec.scala
Wed Aug 29 15:27:49 2012
@@ -125,7 +125,7 @@ object StompCodec extends Log {
           }
       } catch {
           case e:Exception=>
-            throw new IOException("Unable to parser header line [" + line + "]")
+            throw new IOException("Unable to parse header line [" + Log.escape(line) + "]")
       }
       line = read_line
     }
@@ -255,7 +255,7 @@ class StompCodec extends AbstractProtoco
           try {
             var seperatorIndex: Int = line.indexOf(COLON)
             if (seperatorIndex < 0) {
-              throw new IOException("Header line missing seperator [" + line.ascii + "]")
+              throw new IOException("Header line missing seperator [" +  Log.escape(line.ascii)
+ "]")
             }
             var name: Buffer = line.slice(0, seperatorIndex)
             if (trim) {
@@ -272,7 +272,7 @@ class StompCodec extends AbstractProtoco
             headers.add(entry)
           } catch {
             case e: Exception => {
-              throw new IOException("Unable to parser header line [" + line + "]")
+              throw new IOException("Unable to parser header line [" +  Log.escape(line.ascii)
+ "]")
             }
           }
         } else {

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala?rev=1378607&r1=1378606&r2=1378607&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
Wed Aug 29 15:27:49 2012
@@ -39,6 +39,32 @@ object Log {
 
   val exception_id_generator = new AtomicLong(System.currentTimeMillis)
   def next_exception_id = exception_id_generator.incrementAndGet.toHexString
+
+  def escape(o:AnyRef):AnyRef = {
+    o match {
+      case null => null
+      case o:java.lang.Boolean => o
+      case o:java.lang.Byte => o
+      case o:java.lang.Character => o
+      case o:java.lang.Short => o
+      case o:java.lang.Integer => o
+      case o:java.lang.Long => o
+      case o:java.lang.Float => o
+      case o:java.lang.Double => o
+      case _=>
+        val value = o.toString
+        val rc = new StringBuilder(value.length)
+        for(char <- value.toCharArray) {
+          if( (31 < char && char < 127) || Character.isLetterOrDigit(char)
) {
+            rc.append(char)
+          } else {
+            rc.append("\\u%04d".format(char.toInt))
+          }
+        }
+        rc.toString()
+    }
+  }
+
 }
 
 /**



Mime
View raw message