shashank created CAMEL-26303:
--------------------------------
Summary: camel-browse - stopping the route that consumes from a
browse endpoint makes every send to it fail, and removing that route makes them
fail with a NullPointerException
Key: CAMEL-26303
URL: https://issues.apache.org/jira/browse/CAMEL-26303
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: shashank
Assignee: shashank
{{BrowseEndpoint}} keeps the processor of its consumer from {{createConsumer}}
on ({{onExchangeProcessor}}, main c536c99caaaa line 121) and calls it from
{{onExchange}} for every exchange a producer sends to the endpoint. Two
consequences for a route {{from("browse:orders")}} next to the routes that send
{{to("browse:orders")}} (sending to a browse endpoint is the use the component
page documents; {{BrowseRouteConsumeTest}} has both):
# *The consuming route is stopped*: the producers still call the processor of
the stopped route. On main the exchange then fails with
{{RouteStoppingException: The exchange cannot continue: its route is being
stopped or reloaded}} (CAMEL-25502), so the routes that send to the endpoint
fail for as long as the consuming route is stopped. On camel-4.22.x and older
(no {{RouteStoppingException}}) the stopped route still processes the exchanges
(read, not run).
# *The consuming route is removed*: the core stops the endpoint of its consumer
({{RouteService.doShutdown}}) although the other routes still send to it,
{{doStop}} sets the list of exchanges to null (line 189), and every send fails
with {{NullPointerException: Cannot invoke "java.util.List.add(Object)" because
"this.exchanges" is null}} (line 170) until the route is added again.
*Fix*: the consumer sets the processor when it starts and clears it when it
stops (only its own); the endpoint clears its list at stop but keeps it, so the
routes that send to it keep working. The consumer becomes a named class
({{BrowseConsumer}}) instead of a plain {{DefaultConsumer}}. No option or
documented behaviour changes.
*Tests*: new {{BrowseRemoveRouteTest}} (camel-core, where the browse tests
are): {{removeConsumerRoute}} (NullPointerException) and
{{stoppedConsumerGetsNoMessage}} (RouteStoppingException) fail on main (3 runs)
and pass with the fix. With the fix the browse tests of camel-core (14) and the
browsable endpoint tests of camel-management (21) pass.
*How it was found*: a code sweep for endpoints whose {{doStop}} releases
something that other routes on the same uri still use, after a random
lifecycle-sequence harness found the same kind of defect in camel-disruptor
(CAMEL-26286).
*Affected*: main (both), camel-4.22.x, camel-4.18.x and camel-4.14.x (same
code; the removal NPE, and the stopped route that still gets the exchanges;
read, not run).
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)