Skip to content

[backport camel-4.18.x] CAMEL-24187: CamelContext.getEndpoint() never caches a uri containing a % character#24808

Merged
Croway merged 1 commit into
apache:camel-4.18.xfrom
Croway:backport/CAMEL-24187-4.18.x
Jul 16, 2026
Merged

[backport camel-4.18.x] CAMEL-24187: CamelContext.getEndpoint() never caches a uri containing a % character#24808
Croway merged 1 commit into
apache:camel-4.18.xfrom
Croway:backport/CAMEL-24187-4.18.x

Conversation

@Croway

@Croway Croway commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of #24805 to camel-4.18.x (excludes the camel-plc4x test).

  • AbstractCamelContext.doGetEndpoint() normalizes the URI once for cache lookup, but on a cache miss passes the already-normalized URI to addEndpointToRegistry(), which normalizes it a second time. Since EndpointHelper.normalizeEndpointUri() is not idempotent for URIs containing % (each pass encodes %41%2541), the stored registry key never matches a later lookup key — causing getEndpoint() to create a brand-new Endpoint on every call instead of reusing the cached singleton.
  • Adds a normalized-aware overload of getEndpointKey()/addEndpointToRegistry() so the doGetEndpoint() call site skips redundant re-normalization. Public APIs (hasEndpoint, addEndpoint, removeEndpoints) are unchanged.
  • Affects any component whose endpoint URI contains a literal % and is re-resolved by string (pollEnrich/toD/recipientList).

Test plan

  • New test DefaultEndpointRegistryTest#testGetEndpointIsCachedForUriContainingPercentCharacter verifies the fix using controlbus:route?routeId=RAW(%41)&action=status.

Claude Opus 4.6 on behalf of Croway

…point() never caches a uri containing a % character

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean backport of #24805 to camel-4.18.x.

The AbstractCamelContext fix and DefaultEndpointRegistryTest are identical to the main
branch version. The plc4x reproducer test is correctly excluded (component may not be on 4.18.x).

Already reviewed the original PR in detail — the normalized flag correctly prevents
double-normalization of URIs containing %, which made NormalizedUri keys non-idempotent
(%41%2541 on second pass).

Claude Code on behalf of gnodet

@Croway
Croway merged commit d0d6d47 into apache:camel-4.18.x Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants