[ 
https://issues.apache.org/jira/browse/CAMEL-27607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-27607:
--------------------------------
    Fix Version/s: 4.24.0
                       (was: 4.25.0)

> camel-jsonata: stream leak with header template, expression reparsed, unused 
> options
> ------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27607
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27607
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Claus Ibsen
>            Assignee: shashank
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while improving the option descriptions of camel-jsonata for 
> CAMEL-23832 (PR https://github.com/apache/camel/pull/30935).
> These are separate problems of the component; the descriptions PR only 
> documents the current behavior.
> h4. 1. The endpoint resource is opened even when the CamelJsonataResourceUri 
> header replaces it
> {{JsonataEndpoint.onExchange()}} calls {{getResourceAsInputStream()}} before 
> it checks the {{CamelJsonataResourceUri}} header. With 
> {{allowTemplateFromHeader=true}} and the header set, that stream is replaced 
> and never closed. With {{contentCache=false}} this leaks one open resource 
> stream per exchange (a file handle or an HTTP connection). If the endpoint 
> resource does not exist, the exchange fails, although the expression comes 
> from the header.
> Proposed change: check the header first, and open the endpoint resource only 
> when the header is not used.
> h4. 2. The expression is parsed again for each exchange
> {{JsonataEndpoint.onExchange()}} reads the resource text and calls 
> {{Jsonata.jsonata(spec)}} for every exchange, also with 
> {{contentCache=true}}. The content cache keeps only the bytes of the 
> resource, so every message pays the cost of parsing the JSONata expression.
> Proposed change: when {{contentCache=true}}, keep the parsed {{Jsonata}} 
> expression of the endpoint resource and create only a new {{Jsonata.Frame}} 
> per exchange.
> h4. 3. The allowContextMapAll option does nothing
> {{allowContextMapAll}} is inherited from {{ResourceEndpoint}} and shows up in 
> the jsonata options with a text about access to the Exchange and the 
> CamelContext. The jsonata component never builds a context map and never 
> calls {{isAllowContextMapAll()}}, so the option has no effect.
> Proposed change: hide or document the option as not used by jsonata, or bind 
> the exchange data to the frame when it is enabled.
> h4. 4. The CamelJsonataContext constant is not used
> {{JsonataConstants.JSONATA_CONTEXT}} ({{CamelJsonataContext}}) has no 
> {{@Metadata}} and the producer never reads it. Several tests 
> ({{JsonataFirstSampleTest}}, {{JsonataJacksonOutputTest}}, 
> {{JsonataArrayInputTest}}) set the header, which suggests it should do 
> something, but it has no effect.
> Proposed change: remove the constant and its use in the tests, or implement 
> and document the header.
> _Claude Code on behalf of davsclaus_



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

Reply via email to