gnodet-bot commented on code in PR #27581:
URL: https://github.com/apache/camel/pull/27581#discussion_r4221243230
##########
core/camel-support/src/main/java/org/apache/camel/support/processor/MarshalProcessor.java:
##########
@@ -67,6 +73,11 @@ public boolean process(Exchange exchange, AsyncCallback
callback) {
if (variableSend != null) {
body = ExchangeHelper.getVariable(exchange, variableSend);
}
+ if (allowNullBody && body == null) {
+ // the body is null, and it is an allowed value so let's skip the
marshalling
+ callback.done(true);
+ return true;
+ }
Review Comment:
⚠️ **`variableReceive` not cleared on null-body path**
This early return skips the `variableReceive` assignment at line 91. If a
caller combines `allowNullBody=true` with `variableReceive`, the variable will
retain its **previous (stale) value** instead of being set to `null`.
`UnmarshalProcessor` handles this explicitly in its null-body shortcut.
Please mirror that behaviour:
```suggestion
if (allowNullBody && body == null) {
// the body is null, and it is an allowed value so let's skip
the marshalling
if (variableReceive != null) {
ExchangeHelper.setVariable(exchange, variableReceive, null);
}
callback.done(true);
return true;
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]