Skip to content

Commit d697782

Browse files
gnodetclaude
andcommitted
CAMEL-22549: Add inline comments for non-trivial getOut→getMessage changes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 411f1b3 commit d697782

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ public AccessibleObject getStaticPart() {
395395
private void fillResult(Exchange exchange, Object result) {
396396
LOG.trace("Setting bean invocation result : {}", result);
397397

398-
// the bean component forces OUT if the MEP is OUT capable
398+
// the bean component forces OUT if the MEP is OUT capable;
399+
// in.copy() both creates the OUT and propagates headers in one step
399400
if (ExchangeHelper.isOutCapable(exchange) && !ExchangeHelper.hasResponse(exchange)) {
400401
ExchangeHelper.setResponse(exchange, exchange.getIn().copy());
401402
}

components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public void process(Exchange exchange) throws Exception {
108108

109109
ResultHandler resultHandler = resultHandlerFactory.createResult(exchange);
110110
Result result = resultHandler.getResult();
111-
// let's copy the headers before we invoke the transform in case they modify them
111+
// copy headers before invoking the transform; getMessage() returns IN here
112+
// (no OUT yet), so copyFrom is a no-op for headers but sets up the message state
112113
Message out = exchange.getMessage();
113114
out.copyFrom(exchange.getIn());
114115

@@ -489,6 +490,7 @@ protected void configureTransformer(Transformer transformer, Exchange exchange)
489490
addParameters(transformer, getParameters());
490491
transformer.setParameter("exchange", exchange);
491492
transformer.setParameter("in", exchange.getIn());
493+
// only set "out" param if a response exists; avoids creating an empty OUT as side effect
492494
Message response = ExchangeHelper.getResponse(exchange);
493495
if (response != null) {
494496
transformer.setParameter("out", response);

core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ private static void copyFromOutMessage(Exchange result, Exchange source, boolean
442442
*/
443443
public static Message getResultMessage(Exchange exchange) {
444444
if (exchange.getPattern().isOutCapable()) {
445+
// explicitly create response if none exists (preserves old getOut() lazy-creation semantics)
445446
if (!hasResponse(exchange)) {
446447
setResponse(exchange, new DefaultMessage(exchange.getContext()));
447448
}

core/camel-support/src/main/java/org/apache/camel/support/processor/UnmarshalProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public boolean process(Exchange exchange, AsyncCallback callback) {
7777
}
7878
final Message out;
7979
if (allowNullBody && body == null) {
80-
// The body is null, and it is an allowed value so let's skip the unmarshalling
80+
// The body is null, and it is an allowed value so let's skip the unmarshalling;
81+
// use empty response (not in.copy()) so the null body is preserved
8182
ExchangeHelper.setResponse(exchange, new DefaultMessage(exchange.getContext()));
8283
out = exchange.getMessage();
8384
} else {

0 commit comments

Comments
 (0)