davsclaus opened a new pull request, #27451:
URL: https://github.com/apache/camel/pull/27451

   https://issues.apache.org/jira/browse/CAMEL-25387
   
   A Kamelet whose template starts from the Kamelet itself, here `from: 
kamelet:loop-action/route` instead of `kamelet:source`, creates the Kamelet 
again while creating it, until the stack overflows:
   - **At startup:** the JVM died with `Exception in thread "main" 
java.lang.StackOverflowError`, with no mention of the Kamelet.
   - **On a dev-mode reload:** the warning was `Error reloading files in 
directory ... due to: null. This exception is ignored.`
   
   A local model wrote exactly this in a benchmark, and that `null` was all it 
had to go on.
   
   **Fix:**
   - **`KameletComponent`:** creating a Kamelet's route creates the Kamelets 
its template uses, on the same thread. The component now keeps the templates it 
is creating on the thread, and fails when one is entered again:
     ```
     Kamelet loop uses itself: its template uses kamelet:loop, which creates 
the Kamelet again while creating it.
     The template of an action or a sink starts from kamelet:source, the 
message the route sends to the Kamelet
     ```
     A longer cycle would be reported as `a -> b -> a`. In practice, Kamelets 
that only send to each other (`to: kamelet:b` in `a`, `to: kamelet:a` in `b`) 
don't recurse at creation, because the endpoint is cached by uri. So that case 
is not an error, and a test checks that a Kamelet using another Kamelet still 
works.
   - **`FileWatcherResourceReloadStrategy`:** for an error without a message, 
such as `StackOverflowError`, the warning gives its class name instead of 
`null`.
   
   **Tests:**
   - `KameletCycleTest`: a Kamelet that starts from itself fails with the 
message above, and fails with `StackOverflowError` without the change. A 
Kamelet that uses another Kamelet, and one used twice in a route, still work.
   - Suites pass: camel-kamelet (90), camel-support (125), camel-yaml-dsl (458).
   
   The camel-jbang AI validator also reports this template shape when the file 
is written (CAMEL-25379, #27447).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to