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

   # Description
   
   [CAMEL-25836](https://issues.apache.org/jira/browse/CAMEL-25836)
   
   With `allowTemplateFromHeader=true`, a template given in the 
`CamelJteTemplate` header was passed to the JTE engine under the exchange id as 
its name. The runtime JTE engine compiles every template name it has not seen 
into a class. It keeps the class in its template cache and writes the generated 
source and class files to the work directory. So every exchange compiled the 
same template again, and each compile left one more class in memory and two 
more files on disk. Nothing removed them while the context ran, so memory and 
disk use grew without bound.
   
   Changes (`JteEndpoint`):
   - A header template is now named after a SHA-256 digest of its content 
(`header-<hex>`). The same template is compiled once and reused, and the engine 
keeps one class per distinct template text.
   - `JteCodeResolver.addTemplateFromHeader`: the parameter is renamed from 
`exchangeId` to `name` to match its use.
   
   Templates from the endpoint URI or from the `CamelJteResourceUri` header are 
not affected. No option or default changes.
   
   Tests:
   - New `JteTemplateFromHeaderCompiledOnceTest` (2 tests) counts the compiled 
classes in the work directory and checks the output of every exchange. Without 
the change both fail: `expected: <1> but was: <20>` (one template, 20 
exchanges) and `expected: <2> but was: <20>` (two templates, 10 exchanges 
each). With the change both pass.
   - camel-jte unit tests with the change: 6 run, 0 failures.
   
   How it was found: a search for exchange ids used as keys of long-lived maps, 
then reading the JTE 3.2.4 runtime (its template cache is keyed by the template 
name), then the test above.
   
   # 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-25836](https://issues.apache.org/jira/browse/CAMEL-25836).
   
   # 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 and tested camel-jte. No option or generated metadata changed. 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