Claus Ibsen created CAMEL-27790:
-----------------------------------

             Summary: camel-jte: endpoints with a resourceUri of the same 
scheme render the same template, NPE with preCompile, contentCache has no effect
                 Key: CAMEL-27790
                 URL: https://issues.apache.org/jira/browse/CAMEL-27790
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.25.0


Found while improving the option descriptions of camel-jte for CAMEL-23832 
(pull request https://github.com/apache/camel/pull/31134).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. Endpoints with a resourceUri of the same scheme render the same template
In {{JteEndpoint.onExchange}} with allowTemplateFromHeader=false and a 
resourceUri with a scheme ({{ref:}}, {{classpath:}}, {{file:}}, ...), the 
template name is the scheme alone ({{name = before(name, ":")}}), which 
{{JteCodeResolver}} maps to the path. The TemplateEngine caches compiled 
templates by name and {{getLastModified()}} returns 0, so every endpoint with 
the same scheme renders the template compiled first. Confirmed with a scratch 
test: {{jte:ref:t1}} and {{jte:ref:t2}} both returned the output of t1.
Proposed change: use the full URI (or a name derived from it) as the template 
name, as the allowTemplateFromHeader=true branch already does.

h4. 2. NullPointerException with preCompile=true and a resourceUri with a scheme
{{getCodeResolver()}} is null in precompiled mode, so 
{{codeResolver.addPathMapping}} throws.
Proposed change: reject a scheme in precompiled mode with a clear error.

h4. 3. The template header is silently ignored with preCompile=true
CamelJteTemplate is removed and then ignored because there is no code resolver. 
An error or a log line would be clearer.

h4. 4. contentCache has no effect
onExchange never reads the template through 
{{ResourceEndpoint.getResourceAsInputStream()}}, and the engine keeps compiled 
templates until clearContentCache (JMX) or shutdown, so contentCache=false does 
not reload templates.
Proposed change: clear the engine cache when contentCache=false, or deprecate 
the option for jte.


_Claude Code on behalf of davsclaus_



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

Reply via email to