Claus Ibsen created CAMEL-25979:
-----------------------------------

             Summary: camel-language - compile a script from the 
CamelLanguageScript header once, never keep it as the script of the endpoint, 
and remove the header after use
                 Key: CAMEL-25979
                 URL: https://issues.apache.org/jira/browse/CAMEL-25979
             Project: Camel
          Issue Type: Improvement
          Components: camel-language
            Reporter: Claus Ibsen
             Fix For: 4.24.0


With {{allowTemplateFromHeader=true}}, the language producer takes the script 
from the {{CamelLanguageScript}} header ({{LanguageProducer.process}}, main 
e6885df7894d):
* a String script is compiled twice (lines 58 and 104);
* with {{cacheScript=true}} the second compile is stored as the cached 
expression of the endpoint (line 110). With a {{resource:}} script and the 
content cache on, the default, the later exchanges without the header run that 
script instead of the script of the endpoint. With an inline script, the script 
of the endpoint is compiled again on every exchange from then on, and with 
cacheScript the compiled expressions are not stopped or removed (line 121);
* the header stays on the message, so a later language endpoint with 
allowTemplateFromHeader runs the same script again.

Checked on 4.24.0-SNAPSHOT with {{camel run}}: 
{{language:simple:resource:file:script.txt?allowTemplateFromHeader=true&cacheScript=true}},
 with the header on the second of four exchanges only, ran the script of the 
header for exchanges 2, 3 and 4.

Proposal: compile a header script once and use it for that exchange only, cache 
only the script of the endpoint, and remove the header after it is used, as the 
velocity, freemarker and xslt components do with their template headers.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to