CAMEL-24147: camel-lra - URL-encode callback query parameters and fix parseQuery split#24831
Conversation
… parseQuery split Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Claude Code on behalf of gnodet
LGTM — fixes two related URL-handling bugs that silently corrupt LRA callback URLs.
Bug 1 — missing URL-encoding in LRAUrlBuilder.query():
An endpoint URI like seda:cancelOrder?concurrentConsumers=2&size=1000 registered as a compensation callback would have its ?, &, and = characters interpreted as part of the callback URL's own query structure, corrupting the registered callback. The fix correctly applies URLEncoder.encode(value, StandardCharsets.UTF_8) to both key and value.
Bug 2 — split("=") without limit in parseQuery():
Values containing = (e.g., URL-encoded endpoint URIs after decoding, or base64 values) would be silently truncated at the second =. split("=", 2) correctly limits the split to [key, rest-of-value].
Review notes:
-
Both fixes work in concert — the builder now encodes special characters, and the parser correctly handles the full value after decoding.
-
The round-trip test is excellent — verifies that
LRAUrlBuilderencoding +parseQuerydecoding is lossless for realistic compensation URIs with query parameters and special characters. -
URLEncoder.encode()withStandardCharsets.UTF_8is the correct choice — it handles all RFC 3986 reserved characters and thedecode()method already used inparseQuery()usesURLDecoder.decode()with UTF-8. -
No upgrade guide needed — this is a pure bugfix for behavior that was silently broken (data corruption), not a behavioral change users might rely on.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
Summary
Claude Code on behalf of davsclaus
Two related defects in camel-lra cause saga compensation/completion to silently fail when endpoint URIs contain query parameters or special characters:
LRAUrlBuilder.query()concatenated keys and values raw with noURLEncoder. An endpoint URI likeseda:cancelOrder?concurrentConsumers=2&size=1000corrupts the callback URL registered with the LRA coordinator.LRASagaRoutes.parseQuery()usedsplit("=")without a limit, dropping everything after the second=in a value.Changes
LRAUrlBuilder.query(): URL-encode both key and value withURLEncoder.encode()LRASagaRoutes.parseQuery(): usesplit("=", 2)to preserve values containing=LRAUrlBuilderTestwith encoding and round-trip testsLRASagaRoutesTestfor encoded special characters and equals-in-valueTest plan
LRAUrlBuilderTestverifies encoding of special characters, round-trip fidelity, and realistic compensation URIs with query parametersLRASagaRoutesTestcases verifyparseQuery()handles encoded&,=,+and preserves values with=mvn verify🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com