allthingssecurity opened a new pull request, #31000: URL: https://github.com/apache/camel/pull/31000
# Description [CAMEL-27613](https://issues.apache.org/jira/browse/CAMEL-27613) The ticket lists three problems of camel-mustache that came up while the option descriptions were written for CAMEL-23832 (#30949). I checked each one against main and fixed all three. Fixed: 1. **Setting only one of startDelimiter and endDelimiter had no effect.** `MustacheEndpoint.createMustache()` passed custom delimiters to `DefaultMustacheFactory.compile(reader, name, sm, em)` only when both were not null, and both fields defaulted to null. The fields now hold their defaults (`{{` and `}}`), so one delimiter can be set alone and the other keeps its default. With the default delimiters the factory is still called with `compile(reader, name)`, exactly as before; I checked that `DefaultMustacheFactory.compile(Reader, String)` of mustache.java 0.9.14 calls the four-argument method with `{{` and `}}`, so nothing changes for endpoints without delimiters. When delimiters other than the defaults are set but the `mustacheFactory` of the component is not a `DefaultMustacheFactory`, the endpoint logs a WARN once, when it is initialized; the templates are compiled as before. 2. **The defaultValue of the two options did not match the fields.** Fixed with point 1. `getStartDelimiter()` and `getEndDelimiter()` now return `{{` and `}}` instead of null. 3. **Stale class Javadoc of MustacheComponent.** It listed endpoint options, with broken HTML. It is now one sentence. The changed behaviour of point 1 is in the 4.24 upgrade guide. This conflicts with #30949 in `MustacheEndpoint`: #30949 rewrites the `@UriParam` annotations of `startDelimiter` and `endDelimiter` right above the two field lines that this change gives initializers, so whichever is merged second gets a textual conflict there. It is resolved by keeping the annotations of #30949 with the initializers of this change. `MustacheComponent` changes in other lines. Two descriptions in #30949 become wrong with this change: `startDelimiter` says "Only applied when endDelimiter is set too", and `endDelimiter` says "Only applied when startDelimiter is set too". Each one is now applied alone. The rest of those descriptions (only applied with a `DefaultMustacheFactory`, also used for the `CamelMustacheTemplate` header) stays true. Tests (new): - `MustacheDelimiterTest`: a template from the `CamelMustacheTemplate` header is rendered with only `startDelimiter=<%`, with only `endDelimiter=%>`, with both, and with neither; the getters return the defaults. Against the main sources 3 of the 4 fail: with `startDelimiter` alone the tag is not replaced (`Hello <%body}}!`), with `endDelimiter` alone the template fails to compile, and the getters return null. The test with both delimiters passes on main too. Results (offline, module build of camel-mustache, test phase): 13 tests run, 0 failures, 0 errors, 0 skipped. The new test class passes 5 runs in a row. Generated files: none change (the metadata already had the default values). # 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-27613](https://issues.apache.org/jira/browse/CAMEL-27613). # 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-mustache and ran its unit tests; the build regenerates no file for this change. 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]
