davsclaus commented on code in PR #8023:
URL: https://github.com/apache/camel/pull/8023#discussion_r929177351


##########
components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java:
##########
@@ -114,14 +114,20 @@ private Document<?> doEvaluate(Exchange exchange) {
         }
 
         Document<?> body;
+
         if (exchange.getMessage().getBody() instanceof Document) {
             body = (Document<?>) exchange.getMessage().getBody();
+        } else if (exchange.getMessage().getBody() == null || 
"".equals(MessageHelper.extractBodyAsString(exchange.getMessage()))) {
+            //Empty body, force type to be application/java
+            body = new DefaultDocument<>("", MediaTypes.APPLICATION_JAVA);
         } else if (MediaTypes.APPLICATION_JAVA.equalsTypeAndSubtype(bodyMT) || 
bodyMT == null) {
             body = new DefaultDocument<>(exchange.getMessage().getBody());
         } else {
             body = new 
DefaultDocument<>(MessageHelper.extractBodyAsString(exchange.getMessage()), 
bodyMT);

Review Comment:
   You would essentially call this method twice, first when checking for empty, 
and then afterwards here too. I think it would be good to do this only once



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to