gnodet-bot commented on code in PR #26626:
URL: https://github.com/apache/camel/pull/26626#discussion_r4056885968
##########
core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java:
##########
@@ -768,15 +768,24 @@ private static String doDumpMessageHistoryStacktrace(
}
sb.append("\n");
sb.append(
-
"---------------------------------------------------------------------------------------------------------------------------------------\n");
+
"----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
String goMessageHistoryHeader =
exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_HEADER_FORMAT);
sb.append(String.format(goMessageHistoryHeader == null ?
MESSAGE_HISTORY_HEADER : goMessageHistoryHeader,
- "Source", "ID", "Processor", "Elapsed (ms)"));
+ "Source", "ID", "Processor", "Elapsed (ms)", "Body type",
"Size"));
sb.append("\n");
+ // the body as it is now, for the route's own row (the history rows
carry the body as each node was reached)
+ Object body = exchange.getMessage().getBody();
+ String bodyType = body != null ? ObjectHelper.classCanonicalName(body)
: "null";
+ String bodySize = "";
+ if (exchange.getContext().getMessageSizeStrategy() != null
+ && exchange.getContext().getMessageSizeStrategy().isEnabled())
{
+ long size =
exchange.getContext().getMessageSizeStrategy().computeBodySize(exchange.getMessage());
+ bodySize = size >= 0 ? Long.toString(size) : "";
Review Comment:
⚠️ **Inconsistency: null body shows `bodySize="0"` in the route row but `""`
in history rows.**
When `body == null` and the `MessageSizeStrategy` is enabled,
`computeBodySize(exchange.getMessage())` is called here and returns `0` (the
`if (body == null) return 0` fallback in `DefaultMessageSizeStrategy`). Because
`0 >= 0`, `bodySize` is set to `"0"`. The route row then renders as
`bodyType=null, size=0`.
By contrast, the history rows for a null-body node render with an empty size
column (`""`) because `captureBody()` returns early before touching the size
strategy when `body == null`.
A user looking at the failure table sees the route row say `0` while every
null-body history row says nothing — inconsistent within the same table.
Fix: skip `computeBodySize` when `body == null`, mirroring the
`captureBody()` guard:
```suggestion
long size = body != null
?
exchange.getContext().getMessageSizeStrategy().computeBodySize(exchange.getMessage())
: -1;
bodySize = size >= 0 ? Long.toString(size) : "";
```
--
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]