Skip to content

CAMEL-24351: camel-platform-http-starter - the request mapping must not be lazy - #1874

Merged
davsclaus merged 1 commit into
apache:mainfrom
henrik242:camel-platform-http-eager-mapping
Aug 4, 2026
Merged

CAMEL-24351: camel-platform-http-starter - the request mapping must not be lazy#1874
davsclaus merged 1 commit into
apache:mainfrom
henrik242:camel-platform-http-eager-mapping

Conversation

@henrik242

@henrik242 henrik242 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@Lazy was added in 4.21.0, replacing an ObjectProvider that deferred the CamelContext lookup. CamelRequestHandlerMapping registers itself as a PlatformHttpListener and is only notified of endpoints created after it exists, so creating it on first demand is unordered with respect to CamelContext startup. When Camel starts first the mapping learns about no endpoint at all, and every platform-http route answers 404 while reporting itself as started. 4.18.3 and 4.20.0 both instantiated the bean eagerly.

Issue link: CAMEL-24351

@davsclaus
davsclaus requested a review from Croway August 4, 2026 11:57

@davsclaus davsclaus 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.

Good fix for a real user-facing bug — the @Lazy on CamelRequestHandlerMapping caused silent 404s because the mapping registers as a PlatformHttpListener in its constructor and only receives notifications for endpoints created after it exists. When lazy, Camel starts first, registers all endpoints, and the mapping never learns about any of them.

The ObjectProvider<CamelContext> approach is the standard Spring idiom for breaking the circular dependency that motivated @Lazy in the first place. The Javadoc clearly explains the design rationale, and the test covers both the eager-instantiation invariant and actual endpoint mapping.

Minor (non-blocking): the test uses JUnit assertFalse/assertTrue — Camel prefers AssertJ (assertThat(...).isFalse()).

Note: this review covers project conventions and rules compliance. It does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analyzers (SonarCloud).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of @davsclaus

@henrik242
henrik242 force-pushed the camel-platform-http-eager-mapping branch 2 times, most recently from 7d5a6ad to d0f5807 Compare August 4, 2026 12:09
…ot be lazy

@lazy was added in 4.21.0, replacing an ObjectProvider that deferred the
CamelContext lookup. CamelRequestHandlerMapping registers itself as a
PlatformHttpListener and is only notified of endpoints created after it
exists, so creating it on first demand is unordered with respect to
CamelContext startup. When Camel starts first the mapping learns about no
endpoint at all, and every platform-http route answers 404 while reporting
itself as started. 4.18.3 and 4.20.0 both instantiated the bean eagerly.
@henrik242
henrik242 force-pushed the camel-platform-http-eager-mapping branch from d0f5807 to a3b8f47 Compare August 4, 2026 12:13
@davsclaus
davsclaus merged commit 0419afd into apache:main Aug 4, 2026
4 of 5 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.

3 participants