Claus Ibsen created CAMEL-25387:
-----------------------------------
Summary: camel-kamelet - A Kamelet whose template starts from the
Kamelet itself fails with a StackOverflowError instead of saying so
Key: CAMEL-25387
URL: https://issues.apache.org/jira/browse/CAMEL-25387
Project: Camel
Issue Type: Improvement
Components: camel-kamelet
Reporter: Claus Ibsen
Fix For: 4.24.0
A Kamelet template that starts from the Kamelet itself, instead of
{{kamelet:source}}, creates the Kamelet again while creating it, until the
stack overflows.
{noformat}
# loop-action.kamelet.yaml
spec:
template:
from:
uri: kamelet:loop-action/route
steps:
- setBody:
expression:
simple:
expression: "${body}!"
# a route
- to:
uri: kamelet:loop-action
{noformat}
{{camel run}} on 4.23.0-SNAPSHOT: the JVM dies at startup with {{Exception in
thread "main" java.lang.StackOverflowError}}, with no mention of the Kamelet.
The stack repeats {{KameletComponent$LifecycleHandler.track}},
{{AbstractCamelContext.doGetEndpoint}} and {{addService}}. When the same file
is written while an integration runs in dev mode, the reload logs {{Error
reloading files in directory ... due to: null. This exception is ignored.}},
then a StackOverflowError in {{RouteDefinitionHelper.validateUniqueIds}}.
Found in a local model benchmark: the model wrote {{from:
kamelet:tag-order-action/route}} in the template of {{tag-order-action}}, and
the only feedback it got was the reload warning with {{null}}. The camel-jbang
AI validator now reports this template shape (CAMEL-25379), but the runtime
should say it too.
Proposal: when the kamelet component creates a template and the template's
{{from}} is a {{kamelet:}} endpoint of the same Kamelet (or a cycle of
Kamelets), fail with a clear message instead of recursing. For example:
"Kamelet loop-action starts from kamelet:loop-action, itself: the template of
an action or a sink starts from kamelet:source". Separately, the reload warning
should not print {{null}} as the cause for an Error such as StackOverflowError.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)