[
https://issues.apache.org/jira/browse/CAMEL-27038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27038:
--------------------------------
Fix Version/s: 4.24.0
> camel-core - a route whose endpoint failed to create the consumer cannot be
> started again ("services" is null), and a further start starts it without a
> consumer
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27038
> URL: https://issues.apache.org/jira/browse/CAMEL-27038
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: shashank
> Assignee: shashank
> Priority: Major
> Fix For: 4.24.0
>
>
> Found while building the zookeeper-master DST world (CAMEL-26974, PR #30137),
> where a route whose endpoint failed to create its consumer could not be
> started again ("services" is null). Reproduced with a plain unit test
> (below), outside the DST harness.
> h3. What happens
> A route is stopped and started again (from the route controller, JMX, the
> controlbus or a route policy). On the start, {{RouteService.setUp}} sets
> {{setUpDone}} before it runs {{doSetup}}, which calls
> {{endpoint.createConsumer}} (through {{DefaultRoute.initializeServices}}).
> When {{createConsumer}} throws, the start fails with
> {{FailedToStartRouteException}}, as it should, but {{setUpDone}} stays
> {{true}} while the route service has no consumer ({{input}}) and no child
> services (the stop of the route cleared both).
> # The next start skips the set up, and {{doWarmUp}} fails:
> {{startChildServices(route, childServices)}} with {{childServices}} null
> throws {{NullPointerException: Cannot invoke "java.util.List.iterator()"
> because "services" is null}}, wrapped in {{FailedToStartRouteException}}.
> {{warmUpDone}} is set before that work and stays {{true}} as well.
> # The start after that skips the set up and the warm up, finds no consumer,
> and starts the route service: the route reports {{Started}}, but nothing
> consumes (with a direct endpoint, the producer fails with
> {{DirectConsumerNotAvailableException}}).
> So once {{createConsumer}} failed, the route cannot be started again until it
> is removed and added again, and the third attempt reports a started route
> that does not consume.
> h3. Expected
> {{RouteController.startRoute}}: "Starts the given route if it has been
> previously stopped", and it throws "if the route could not be started for
> whatever reason". A failed start leaves the route stopped; once the cause is
> gone (the endpoint can create the consumer again), a later start sets the
> route up and starts it with its consumer.
> h3. Reproduction
> New {{RouteStartAfterFailedCreateConsumerTest}} (camel-core): a route from a
> direct endpoint whose {{createConsumer}} throws while a flag is set. The
> route is stopped, the flag set, {{startRoute}} fails as expected; then the
> flag is cleared and the route started again.
> * {{routeStartsOnceTheConsumerCanBeCreated}}: on main the second start fails
> with the NullPointerException above.
> * {{routeStartsAfterTwoFailedStarts}}: two failed starts, then a start that
> succeeds: on main the route is {{Started}}, and a message sent to it fails
> with {{DirectConsumerNotAvailableException}}.
> h3. Fix
> {{RouteService.setUp}}: when {{doSetup}} throws, the partial state is cleared
> ({{input}}, {{childServices}}) and {{setUpDone}} is set back to {{false}}, so
> the next start sets the route up again (and creates the consumer). Branch
> {{camel-core-route-start-after-failed-create-consumer}}.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)