davsclaus opened a new pull request, #25810: URL: https://github.com/apache/camel/pull/25810
## Summary `URISupport.normalizeUri()` is used to compute the endpoint registry cache key so that two logically identical endpoint URIs (differing only in query parameter order) resolve to a single shared `Endpoint`. This held true in general, but the fast normalizer path (`buildReorderingParameters()`) only rebuilt the query string - which is also the only place where parameter values get URL-encoded - when it detected the parameter keys were **not** already alphabetically ordered. As a result, two semantically identical URIs could normalize to two different strings whenever a value needed URL-encoding (eg a colon in a `host:port` value), depending purely on whether the original, incidental parameter order happened to already be sorted: ``` kafka:mytopic?brokers=localhost:19092&groupId=mygroup -> kafka://mytopic?brokers=localhost:19092&groupId=mygroup (not encoded, keys already sorted) kafka:mytopic?groupId=mygroup&brokers=localhost:19092 -> kafka://mytopic?brokers=localhost%3A19092&groupId=mygroup (encoded, keys needed reordering) ``` Since these two outputs differ, `CamelContext.getEndpoint()` would silently create a **duplicate endpoint** (and thus duplicate producers/consumers, connections, threads) instead of reusing the cached one - with no error or log warning. The fix makes the fast path always rebuild (and thereby always consistently encode) the query string, exactly matching the behavior already used unconditionally by the complex/legacy normalizer path (`doComplexNormalizeUri()`), which was never affected by this bug. See [CAMEL-24524](https://issues.apache.org/jira/browse/CAMEL-24524) for the full root-cause analysis (this was an unintended side effect of a performance optimization added in CAMEL-14648, not a deliberate design decision). ## Test plan - [x] Added regression tests in `URISupportTest` covering: colon values with 2 and 3 parameters in all orderings, single-parameter colon values, comma values, duplicate/list-valued keys with colon values, `RAW(...)` values (must remain unaffected), and idempotency of double-normalization. - [x] `mvn test` passes in `core/camel-util` (61/61 tests, including 7 new). - [x] `DefaultEndpointRegistryTest` in `core/camel-core` (endpoint caching) passes unaffected. - [x] Searched the repo for tests asserting literal endpoint URI strings with colon-containing query values that could rely on the old (buggy) pass-through behavior - none found. _Claude Code on behalf of davsclaus_ Co-Authored-By: Claude Sonnet 5 <[email protected]> -- 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]
