gnodet opened a new pull request, #31193: URL: https://github.com/apache/camel/pull/31193
## Summary Two bugs in `camel-xslt` fixed together: 1. **NPE in `XsltBuilder.tryAddEntityResolver()`** — a `SAXSource` constructed with `SAXSource(InputSource)` leaves its `XMLReader` unset (`null`); the transformer creates its own reader internally. The existing code called `source.getXMLReader().setEntityResolver(…)` without null-checking `getXMLReader()`, so any route using `entityResolver` with a reader-less `SAXSource` body and `secureProcessing=false` threw a `NullPointerException`. 2. **Wrong `defaultValue` on `xpathTotalOpLimit`** — `XsltEndpoint` and `XsltComponent` declared `@UriParam(defaultValue="10000")` / `@Metadata(defaultValue="10000")`, but the Java field initialises to `0`. The value `0` is the sentinel meaning _"consult the component-level value, or leave the JDK default (10000) in effect"_; changing the field to `10000` would silently break the component→endpoint override chain. The annotations, Javadoc descriptions, and all four generated JSON descriptors are corrected to `defaultValue="0"`. ## Root Cause - `SAXSource(InputSource)` is a single-argument constructor that sets no `XMLReader`. `SAXSource.getXMLReader()` returns `null` for such instances — this is documented SAX behaviour. The guard `if (this.entityResolver != null && source != null)` missed the null reader check. - The `@UriParam(defaultValue="10000")` annotation was added to document the _effective_ JDK default visible to users, but the Java field is intentionally `0` (a sentinel), and the resolution logic `xpathTotalOpLimit > 0 ? xpathTotalOpLimit : component.getXpathTotalOpLimit()` relies on that. ## Fix - `XsltBuilder.tryAddEntityResolver()`: added `source.getXMLReader() != null` guard before calling `setEntityResolver`. - `XsltEndpoint` / `XsltComponent`: corrected `defaultValue` from `"10000"` to `"0"` in `@UriParam` / `@Metadata`, updated descriptions to say _"0 (default) leaves the JDK default (10000) in effect"_, and updated all four generated JSON descriptors (`xslt.json` and `xslt-saxon.json` in both `src/generated/` and the catalog mirror). ## Tests `XsltBuilderSAXSourceNPETest` in `camel-xslt-saxon` (tests live there per the module's convention) covers both fixes: - `testSAXSourceWithoutXMLReaderDoesNotNPEWhenEntityResolverSet` — sends a `SAXSource(InputSource)` body through a route configured with `entityResolver=#resolver&secureProcessing=false`; asserts the transformation succeeds without NPE. - `testXpathTotalOpLimitJavaFieldDefaultIsZero` — asserts that the `xpathTotalOpLimit` field defaults to `0` so the component-level value is consulted. Fixes https://issues.apache.org/jira/browse/CAMEL-27908 --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- 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]
