CAMEL-24351: camel-platform-http-starter - the request mapping must not be lazy - #1874
Conversation
davsclaus
left a comment
There was a problem hiding this comment.
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
7d5a6ad to
d0f5807
Compare
…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.
d0f5807 to
a3b8f47
Compare
@Lazywas 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