shashank created CAMEL-24924:
--------------------------------
Summary: Failover load balancer with no processors never completes
the exchange, so the caller hangs
Key: CAMEL-24924
URL: https://issues.apache.org/jira/browse/CAMEL-24924
Project: Camel
Issue Type: Bug
Components: camel-core
Reporter: shashank
A route with a failover load balancer that has no outputs starts without any
error, but every exchange sent to it hangs:
{code:java}
from("direct:fo0").loadBalance().failover().end().setBody(constant("after"));
from("direct:forr0").loadBalance().failover(-1, false,
true).end().setBody(constant("after"));
{code}
{{template.requestBody("direct:fo0", "x")}} never returns. Nothing is logged
and no exception is set on the exchange. The same route with {{roundRobin()}}
instead of {{failover()}} returns straight away and continues with the next
step.
Cause: {{FailOverLoadBalancer.State.run()}} assumes there is at least one
processor. In the default mode it reaches "no more processors to try" and calls
{{ExchangeHelper.copyResults(exchange, copy)}} with {{copy == null}}, which
throws a {{NullPointerException}}. In round robin or sticky mode it calls
{{processors[0]}} on an empty array ({{ArrayIndexOutOfBoundsException}}). Both
happen inside a task on the reactive executor, before {{callback.done}} is
called, so the exchange is never completed.
Proposed fix: when there are no processors, complete the exchange straight away
({{callback.done(true)}}), as {{QueueLoadBalancer}} and {{TopicLoadBalancer}}
already do.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)