allthingssecurity opened a new pull request, #30986:
URL: https://github.com/apache/camel/pull/30986

   # Description
   
   [CAMEL-27607](https://issues.apache.org/jira/browse/CAMEL-27607)
   
   The ticket lists four problems of camel-jsonata found while the option 
descriptions were written for CAMEL-23832 (#30935). I checked each one against 
main and all four are real. Points 1, 3 and 4 are fixed here. Point 2 is not 
changed, for the reason below.
   
   1. **The endpoint resource was opened even when the header replaced it.** 
`onExchange()` opened the endpoint resource before reading 
`CamelJsonataResourceUri`. With `allowTemplateFromHeader=true` and the header 
set, that stream was dropped without being closed, so with `contentCache=false` 
every exchange leaked one resource stream. A missing endpoint resource also 
failed the exchange, even though the expression came from the header. The 
header is now read first, and the endpoint resource is opened only when the 
header does not replace it.
   2. **Not changed: the expression is still parsed for every exchange.** 
Keeping one parsed `Jsonata` expression per endpoint is not safe with dashjoin 
jsonata 0.9.10. `$now()` and `$millis()` read the timestamp from a per-thread 
copy of the expression (the static `ThreadLocal` `Jsonata.current`), and that 
copy is made only once, on the first evaluation on a thread. With a shared 
parsed expression, every thread except the one that parsed it would return the 
time of its first evaluation forever (for example `seda` with 
`concurrentConsumers`). Parsing per exchange, as main does, builds a new 
`Jsonata` on the calling thread, so the clock is right. Caching would need a 
change in dashjoin jsonata first; I will raise it there.
   3. **allowContextMapAll did nothing.** `JsonataEndpoint` now declares the 
option itself and marks it deprecated, with a description and deprecation note 
that say it has no effect in jsonata (the ticket allows hiding or documenting 
it). I chose to deprecate it rather than hide it with `excludeProperties`: 
hiding it would also remove `allowContextMapAll(..)` from the endpoint DSL, and 
Java code that calls it would stop compiling. It stays in the catalog, the docs 
and the endpoint DSL, where it is now marked deprecated.
   4. **CamelJsonataContext was not used.** The producer never reads 
`JsonataConstants.JSONATA_CONTEXT`. I deprecated it rather than removing it, so 
code that references it still compiles. The three tests that set the header no 
longer do.
   
   The 4.24 upgrade guide has a short entry for the two deprecations. No route 
changes its behaviour.
   
   This touches the same generated files as #30935. Whichever is merged second 
needs a small rebase. #30935 does not describe `allowContextMapAll` or 
`CamelJsonataContext`, so there is no conflict of meaning.
   
   Tests (new `JsonataExpressionResourceTest`):
   - `headerExpressionDoesNotNeedTheEndpointResource`: an expression from the 
header works when the endpoint resource does not exist (`contentCache=false`)
   - `endpointResourceIsOpenedOnlyWithoutHeaderExpression`: with the header the 
endpoint resource is not opened at all, and without it the stream is opened 
once and closed
   - `allowContextMapAllIsDeprecated`: the option is deprecated in the 
component metadata, and a URI that sets it still works
   
   Against the main sources all 3 fail for behavioural reasons 
(`FileNotFoundException` for the endpoint resource, the resource opened once 
with the header, `"deprecated": false`).
   
   Results (offline, module build of camel-jsonata, test phase): 29 unit tests 
run, 0 failures, 0 errors. `JsonataExpressionResourceTest` passes 5 runs in a 
row.
   
   Generated files: `jsonata.json` of the component and its catalog copy, and 
`JsonataEndpointBuilderFactory` (the option is marked `@Deprecated`). The 
endpoint configurer and URI factory do not change.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-27607](https://issues.apache.org/jira/browse/CAMEL-27607).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built camel-jsonata and ran its unit tests, and committed its 
regenerated files. The catalog copy is the same JSON, and the endpoint DSL was 
regenerated from it with the camel-package-maven-plugin DSL goal. I did not run 
the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to