Claus Ibsen created CAMEL-27675:
-----------------------------------

             Summary: camel-jolt: contentCache=false ignored, context header 
CCE, transform lost on clear
                 Key: CAMEL-27675
                 URL: https://issues.apache.org/jira/browse/CAMEL-27675
             Project: Camel
          Issue Type: Bug
          Components: camel-jolt
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of camel-jolt for CAMEL-23832 (PR 
(commit 
https://github.com/apache/camel/commit/006d20c896ceeb3512c744acc79c87373654d069)).
These are separate problems of the component; the descriptions commit only 
documents the current behavior.

h4. 1. contentCache=false does not read a changed spec again
{{JoltEndpoint.getTransform()}} builds the JOLT transform from the spec at the 
first exchange and keeps it in the {{transform}} field, whatever 
{{contentCache}} is. Only {{JoltEndpoint.clearContentCache()}} (the JMX 
operation) resets it. So with {{contentCache=false}} the endpoint still uses 
the spec it read first, and a changed spec file is never picked up.
Proposed change: keep the built transform only when {{contentCache}} is true, 
and build it again for each exchange (or when the resource changed) otherwise.

h4. 2. The CamelJoltContext header fails with a ClassCastException for every 
transformDsl except Chainr
With {{allowTemplateFromHeader=true}} and the {{CamelJoltContext}} header set, 
{{JoltEndpoint.onExchange()}} casts the transform to {{ContextualTransform}}. 
Of the {{transformDsl}} types only {{Chainr}} implements it; {{Shiftr}}, 
{{Defaultr}}, {{Removr}} and {{Sortr}} do not, and neither does a component 
{{transform}} that is only a {{Transform}}. The exchange fails with a 
{{ClassCastException}}.
Proposed change: call {{transform(input)}} when the transform is not a 
{{ContextualTransform}} (and log that the context is ignored), or fail with a 
clear message.

h4. 3. clearContentCache() drops the transform of the component transform option
{{JoltComponent.createEndpoint()}} sets the component {{transform}} on the 
endpoint with {{setTransform()}}. {{JoltEndpoint.clearContentCache()}} sets 
that field to null, so after the JMX operation the next exchange builds a 
transform from the {{resourceUri}} of the endpoint instead (for {{jolt:dummy}} 
this fails as the resource does not exist).
Proposed change: keep the configured transform apart from the transform built 
from the spec, and clear only the latter.

h4. 4. inputType and outputType have no default value in the code
Both options declare {{defaultValue = "Hydrated"}} in their {{@UriParam}}, but 
the fields of {{JoltEndpoint}} have no initializer, so {{getInputType()}} and 
{{getOutputType()}} return null. The code treats null as Hydrated, so the 
behavior is the same, but code that reads the getters sees null.
Proposed change: initialize both fields to {{JoltInputOutputType.Hydrated}}.

h4. 5. The doc page URI format names the wrong path and a Velocity file
The "URI format" section of {{jolt-component.adoc}} shows 
{{jolt:specName[?options]}}, while the path option is {{resourceUri}}, and 
gives {{file://folder/myfile.vm}} as an example, a Velocity file name.
Proposed change: use {{jolt:resourceUri[?options]}} and a {{.json}} example.

_Claude Code on behalf of davsclaus_



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

Reply via email to