camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-8303: Storing a string in couchdb should parse it to json properly. Thanks to Lars Rothberg-Hansen for the patch.
Date Sun, 15 Feb 2015 17:07:35 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 725e53c32 -> cc21a31dc
  refs/heads/master 0713b95e2 -> e0bcc700c


CAMEL-8303: Storing a string in couchdb should parse it to json properly. Thanks to Lars Rothberg-Hansen
for the patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e0bcc700
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e0bcc700
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e0bcc700

Branch: refs/heads/master
Commit: e0bcc700cd6769f9f4630c0285cc9358caa35ac1
Parents: 0713b95
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Feb 15 18:07:45 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Feb 15 18:07:45 2015 +0100

----------------------------------------------------------------------
 .../org/apache/camel/component/couchdb/CouchDbProducer.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e0bcc700/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
index 97ad41b..5ae5cef 100644
--- a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
+++ b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
@@ -16,9 +16,10 @@
  */
 package org.apache.camel.component.couchdb;
 
-import com.google.gson.Gson;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.impl.DefaultProducer;
@@ -51,7 +52,11 @@ public class CouchDbProducer extends DefaultProducer {
     JsonElement getBodyAsJsonElement(Exchange exchange) throws InvalidPayloadException {
         Object body = exchange.getIn().getMandatoryBody();
         if (body instanceof String) {
-            return new Gson().toJsonTree(body);
+            try {
+                return new JsonParser().parse((String) body);
+            } catch (JsonSyntaxException jse) {
+                throw new InvalidPayloadException(exchange, body.getClass());
+            }
         } else if (body instanceof JsonElement) {
             return (JsonElement) body;
         } else {


Mime
View raw message