You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/03/01 20:13:09 UTC
[GitHub] [camel] davsclaus commented on a change in pull request #7073: CAMEL-17720: camel-jackson - Add option to allow jackson to support null body
davsclaus commented on a change in pull request #7073:
URL: https://github.com/apache/camel/pull/7073#discussion_r817102082
##########
File path: core/camel-support/src/main/java/org/apache/camel/support/processor/UnmarshalProcessor.java
##########
@@ -55,13 +55,16 @@ public boolean process(Exchange exchange, AsyncCallback callback) {
InputStream stream = null;
Object result = null;
try {
- stream = exchange.getIn().getMandatoryBody(InputStream.class);
+ final Message in = exchange.getIn();
+ final Message out = exchange.getOut();
Review comment:
Do not call getOut() to early as it will create an empty message, and cause the exchange to have this empty message as the response, even if the message body is null and allow null enabled. So move this out to later where its first in use
##########
File path: core/camel-api/src/main/java/org/apache/camel/spi/DataFormat.java
##########
@@ -54,4 +54,13 @@
* @throws Exception can be thrown
*/
Object unmarshal(Exchange exchange, InputStream stream) throws Exception;
+
+ /**
+ * Indicates whether {@code null} is allowed as value of a body to unmarshall.
+ *
+ * @return {@code true} if {@code null} is allowed, {@code false} otherwise.
+ */
+ default boolean allowNullBody() {
Review comment:
Yeah I can't think of a better way as there is no common DataFormatConfiguration class that they all extend etc where we could have common options.
But this is really a useful feature to let the data format not fail on null bodies.
Especially for use-cases with json where we would often use jackson.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org