incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: JSON escaping trace params.
Date Wed, 19 Mar 2014 01:51:28 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/apache-blur-0.2 444cd4adf -> 859e37c40


JSON escaping trace params.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/859e37c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/859e37c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/859e37c4

Branch: refs/heads/apache-blur-0.2
Commit: 859e37c4076200a7107ae85f9bcbc6dd36c4616d
Parents: 444cd4a
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Mar 18 21:51:24 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Mar 18 21:51:24 2014 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/blur/trace/TracerImpl.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/859e37c4/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java b/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
index 629b241..89a9345 100644
--- a/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
+++ b/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
@@ -19,6 +19,7 @@ package org.apache.blur.trace;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.blur.trace.Trace.Parameter;
+import org.json.JSONObject;
 
 public class TracerImpl implements Tracer {
 
@@ -111,9 +112,18 @@ public class TracerImpl implements Tracer {
       if (builder.length() != 0) {
         builder.append(',');
       }
-      builder.append("{\"").append(parameter._name).append("\":\"").append(parameter._value).append("\"}");
+      builder.append("{\"").append(toJsonString(parameter._name)).append("\":\"")
+          .append(toJsonString(parameter._value)).append("\"}");
     }
     return builder.toString();
   }
 
+  private String toJsonString(Object o) {
+    if (o == null) {
+      return null;
+    }
+    String str = o.toString();
+    return JSONObject.quote(str);
+  }
+
 }


Mime
View raw message