Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Unknown
Description
According to the documentation, it should be possible to send through an Exchange with the body containing a String
"If the body is an instance of String, then it will be marshalled into a GSON object before insert."
When doing this, an InvalidPayloadException occurs.
The culprit is this line in the CouchDbProducer:
"return new Gson().toJsonTree(body)"
According to the Gson documentation, this should not be executed on Generic types as the String will not be parsed, but stored in a JsonPrimitive as opposed to the expected JsonObject.
In order to correct it, is to use the code which parses the String (Sorry, don't have time just now to do a proper patch):
try{
return new JsonParser().parse((String)body);
}catch(JsonSyntaxException jse){
throw new InvalidPayloadException(exchange, body != null ? body.getClass() : null);
}
It's also worth mentioning that existing test cases does not result in this Exception and the original 2.14.1 code base as long as my local modified version both passes the tests.