rzo1 opened a new pull request, #1081: URL: https://github.com/apache/opennlp/pull/1081
Backport of #1066 to `opennlp-1.x`. > **Stacked on #1080** (OPENNLP-1819). Base is `OPENNLP-1819-1.x`; please merge #1080 first, after which GitHub will retarget this PR to `opennlp-1.x`. ## Problem Some XML parser implementations (notably on Android, or alternative JAXP providers) do not support every hardening option `XmlUtil` sets. Applying them unconditionally made `createDocumentBuilder()` / `createSaxParser()` throw, breaking otherwise-valid parsing. ## Fix Each `setFeature` / `setAttribute` / `setXIncludeAware` / `setProperty` call moves into a `set...IfSupported` helper that catches the platform-specific failure (`ParserConfigurationException`, `SAXNotRecognizedException` / `SAXNotSupportedException`, `IllegalArgumentException`, `UnsupportedOperationException`), warns, and continues. The remaining options are still applied. ## 1.x adaptations vs. the 2.x change - Test ported from JUnit 5 to JUnit 4. - Warnings via `System.err` (no slf4j on this branch). - The throwing test factory resolves its delegate by temporarily clearing the factory system property instead of Java 9's `DocumentBuilderFactory.newDefaultInstance()`, so it compiles on Java 8. Tests: `XmlUtilTest` passes on Temurin JDK 8; the tolerance branch is exercised (warnings logged, parsing still succeeds). -- 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]
