davsclaus commented on code in PR #29873:
URL: https://github.com/apache/camel/pull/29873#discussion_r4572877878


##########
components/camel-language/src/main/java/org/apache/camel/component/language/LanguageProducer.java:
##########
@@ -135,6 +117,52 @@ public void process(Exchange exchange) throws Exception {
         }
     }
 
+    /**
+     * Evaluates the script of the {@link LanguageConstants#LANGUAGE_SCRIPT} 
header, if there is one. The script is for
+     * this exchange only: it is compiled once, never cached as the script of 
the endpoint, and the header is removed so
+     * a later language endpoint does not run it again.
+     *
+     * @return true if the header had a script, false to use the script of the 
endpoint
+     */
+    private boolean processHeaderScript(Exchange exchange) throws Exception {
+        Expression exp = 
exchange.getIn().getHeader(LanguageConstants.LANGUAGE_SCRIPT, Expression.class);
+        boolean compiled = false;
+        if (exp == null) {
+            String script = 
exchange.getIn().getHeader(LanguageConstants.LANGUAGE_SCRIPT, String.class);
+            if (script == null) {
+                return false;
+            }
+            // the script may be a file: so resolve it before using
+            script = getEndpoint().resolveScript(script);
+            Class<?> type = resultType != Object.class ? resultType : null;
+            exp = getEndpoint().getLanguage().createExpression(script, new 
Object[] { type });
+            exp.init(getEndpoint().getCamelContext());
+            compiled = true;
+        }
+        exchange.getIn().removeHeader(LanguageConstants.LANGUAGE_SCRIPT);
+
+        // the expression compiled from the script is used once, so it is 
always stopped after use

Review Comment:
   The comment is about the expression compiled from the String script 
(`compiled=true`), which is always stopped. A user-supplied `Expression` in the 
header is not compiled, so the comment does not claim it is stopped. The line 
is the same as on main (#29751), and the backport stays identical to it.
   
   _Claude Code on behalf of davsclaus_



-- 
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