Claus Ibsen created CAMEL-27779:
-----------------------------------
Summary: camel-freemarker: encoding ignored for a resourceUri with
a scheme, clearContentCache incomplete, endpoint options not applied to a
custom configuration
Key: CAMEL-27779
URL: https://issues.apache.org/jira/browse/CAMEL-27779
Project: Camel
Issue Type: Bug
Components: camel-freemarker
Reporter: Claus Ibsen
Fix For: 4.25.0
Found while improving the option descriptions of camel-freemarker for
CAMEL-23832 (pull request https://github.com/apache/camel/pull/31132).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. encoding is ignored for a resourceUri with a scheme
For {{classpath:}}, {{file:}}, {{http:}}, {{ref:}}, {{bean:}} or {{resource:}}
URIs, {{FreemarkerEndpoint.onExchange}} reads the template with {{new
InputStreamReader(getResourceAsInputStream())}}, which uses the JVM default
charset. Only a resourceUri without a scheme goes through
{{configuration.getTemplate(path, encoding)}}.
Proposed change: build the reader with {{encoding}}, falling back to the
encoding of the Configuration.
h4. 2. clearContentCache does not clear the cached content of a resourceUri
with a scheme
{{FreemarkerEndpoint.clearContentCache}} overrides
{{ResourceEndpoint.clearContentCache}} without calling super, so the JMX
operation never clears the cached bytes.
Proposed change: also call {{super.clearContentCache()}}.
h4. 3. Creating an endpoint clears the template cache of all endpoints
Each endpoint gets {{configuration.clone()}}; in FreeMarker the clone shares
the CacheStorage and clears it. Creating any endpoint (or calling
clearContentCache) clears the cached templates of all endpoints of the
component. Performance only.
Proposed change: give each clone its own cache storage.
h4. 4. localizedLookup, templateUpdateDelay and contentCache=false are ignored
with a custom configuration
They are applied only to the Configuration the component creates; an endpoint
or component {{configuration}} is used as it is, without a warning. The
descriptions now say so.
h4. 5. templateUpdateDelay=0 cannot be set
Only a value > 0 is applied, so FreeMarker's 0 (check on every call) cannot be
set through the option. Changing the endpoint setter after creation has no
effect, as the value is only read in createEndpoint.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)