[
https://issues.apache.org/jira/browse/CAMEL-27515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150325#comment-18150325
]
Federico Mariani commented on CAMEL-27515:
------------------------------------------
[~davsclaus] one part of this looks like a 4.24.0 regression, which may need a
decision before the release, apart from the rest of this issue.
On main, a {{VirtualMachineError}} thrown by a {{.process(...)}} step is
swallowed on the first delivery when the error handler uses {{RedeliveryTask}}:
a dead letter channel, redelivery, or an {{onException}} policy.
{{DelegateSyncProcessor}} calls the callback before it throws the {{Error}} on,
and since CAMEL-26446 {{RedeliveryErrorHandler}} then only logs a WARN ("...
The exchange continued, so this exception is ignored."). The rest of the route
runs at once, as if the step had succeeded, and the caller gets success. An
unconfigured default error handler still throws the {{Error}} to the caller, as
in 4.23.0.
{{.bean()}} steps changed on main as well: on 4.23.0 a bean's
{{StackOverflowError}} goes through redelivery, {{onException}} and the dead
letter channel; on main the bean is called once, none of them runs, and the
caller gets success.
Reproduced in a Camel Main app with platform-http. A {{POST /orders}} whose
pricing step overflows the stack returns HTTP 200 "created", the order is saved
with {{total=null}}, and the dead letter channel gets nothing. On 4.23.0 the
same app returns HTTP 500. It still saves the half-built order later, on the
next request that runs on the same worker thread, which is the older part of
this issue.
A prototype that fails the exchange and keeps the {{Error}} away from
{{onException}}, redelivery and the dead letter channel returns HTTP 500 and
saves nothing. I'll follow up here with the options to fix it.
_Claude Code on behalf of Croway_
> camel-core - after a VirtualMachineError thrown by a processor, the rest of
> the route runs later on the next exchange of the same thread
> ----------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27515
> URL: https://issues.apache.org/jira/browse/CAMEL-27515
> Project: Camel
> Issue Type: Sub-task
> Components: camel-core
> Reporter: Federico Mariani
> Assignee: Federico Mariani
> Priority: Major
>
> A plain {{Processor}} that throws a {{VirtualMachineError}}
> ({{OutOfMemoryError}}, {{StackOverflowError}}) leaves the rest of its route
> queued on the thread. The next exchange processed on that thread runs it: the
> failed exchange goes on through its route, with no exception set, as if the
> processor had succeeded.
> {{DelegateSyncProcessor}} (and the bridge of
> {{AsyncProcessorConverterHelper}}) calls the callback in {{finally}}, then
> throws the {{VirtualMachineError}} on, with no exception set on the exchange.
> The callback queues the next step of the route on the reactive worker of the
> thread. The {{Error}} then leaves {{DefaultReactiveExecutor}}, whose
> {{doRun}} catches only {{Exception}}, and the queued step stays there until
> the next exchange on that thread runs it. CAMEL-26741 fixed this for the
> other {{Error}}s and left a {{VirtualMachineError}} as before.
> {{error-handler.adoc}} says that the exchange may stay inflight, but not that
> it can go on later.
> Reproduced on 4.18.5, 4.23.0 and main:
> {code:java}
> from("direct:a")
> .process(e -> { throw new StackOverflowError("simulated"); })
> .process(e -> probe.add("route a step 2: body=" +
> e.getMessage().getBody() + " exception=" + e.getException()));
> from("direct:b").process(e -> probe.add("route b"));
> template.sendBody("direct:a", "to-a"); // throws the StackOverflowError,
> probe is empty
> template.sendBody("direct:b", "to-b"); // probe = [route b, route a step 2:
> body=to-a exception=null]
> {code}
> Why it matters now: the consumer fixes under CAMEL-27469 keep the thread
> alive after a {{VirtualMachineError}}.
> * With CAMEL-27470 merged, take two timer routes on the same timer. After
> route A throws, its next step runs on a tick of route B, after the ERROR line
> said that route A no longer fires. With the pooled exchange factory and
> {{synchronous=true}}, it runs on an exchange that {{TimerConsumer}} has
> already released and reset, so it gets an empty message.
> * A loop that goes on after a {{VirtualMachineError}}, as planned for
> camel-seda in CAMEL-27471, would run it on its next exchange.
> * When nothing else runs on the thread, the exchange stays inflight, and
> stopping the route waits for the shutdown timeout.
> Possible fixes, to agree on CAMEL-27469:
> * Before calling the callback, mark the exchange so that the queued steps do
> not run and its on completions see a failure. The {{Error}} is still thrown
> on, and still not given to Camel's error handling (CAMEL-26741).
> * Do not call the callback for a {{VirtualMachineError}}. Nothing is queued,
> but a caller that waits for the callback on another thread would wait forever.
> * The reactive worker drops the queued work of the failed exchange when an
> {{Error}} leaves {{doRun}}, without dropping unrelated work.
> A test: a route with two steps where the first throws a
> {{StackOverflowError}}, then another exchange on the same thread. The second
> step and the on completions of the first exchange must not run.
> _Claude Code on behalf of Croway_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)