mayurbm commented on PR #25871: URL: https://github.com/apache/camel/pull/25871#issuecomment-5452558563
@Croway @davsclaus Thank you both for the feedback. The PR has been reworked to address the review comments. Here is what changed: **1. `TypeConversionException.createMessage()` — stops `toString()` on body (Croway's primary ask)** Replaced `+ value` with `safeValueDescription(value)` that **never calls `toString()` on unknown types**: - `CharSequence`: truncated preview (max 64 chars) + length - `byte[]`: `byte[N]` - `File` / `Path`: path string only - `ByteBuffer`: `ByteBuffer[remaining=N]` - Everything else: `ClassName@identityHash` — no `toString()` call Regression test added: `testTypeConversionExceptionDoesNotCallToStringOnBody` uses an `Object` with a `toString()` that sets an `AtomicBoolean` — asserts it is never called. **2. `MessageSupport.getMandatoryBody()` — v2 guard (addresses Croway's semantics concern)** The v1 guard incorrectly blocked same-type bodies (`String` → `String`). The new `wouldMaterializeHugeBulk()` **only fires when a conversion would actually allocate** — if the body is already the target type it passes through unchanged (heap cost already paid, no extra allocation). Key improvements: - Same-type bodies always pass through ✅ - Richer length detection: `CharSequence`, `byte[]`, `ByteBuffer`, `StreamCache`, `File`, `Path`, `CamelFileLength`/`Content-Length` headers, `GenericFile.getFileLength()` duck-type - Cap hierarchy: exchange property `CamelConvertMaxBytes` → context global option → system property `camel.convert.max-bytes` → **16 MiB default** (down from v1's 256 MiB) **Would you agree this v2 approach correctly addresses both OOM paths while keeping `getMandatoryBody()` semantics intact?** Happy to adjust if the guard still doesn't belong in `MessageSupport` — in that case the `TypeConversionException` fix alone would be the scoped change. Local test results: `camel-api` + `camel-support` + `camel-core` full suites — 12 new tests pass, no regressions from our changes. _Claude Code on behalf of mayurbm_ -- 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]
