Skip to content

Fixed exception expectation in testDeeplyNestedElements#606

Merged
coheigea merged 1 commit into
apache:mainfrom
kuzjka:fix/deep_nesting_test
Jun 5, 2026
Merged

Fixed exception expectation in testDeeplyNestedElements#606
coheigea merged 1 commit into
apache:mainfrom
kuzjka:fix/deep_nesting_test

Conversation

@kuzjka
Copy link
Copy Markdown
Contributor

@kuzjka kuzjka commented Jun 5, 2026

Fixes the test for recent Java versions.

The test has two success paths:

  1. Overflow limit is not hit, exception is not thrown.
  2. Exception is thrown and it contains specific text, indicating that overflow protection is triggered.

Depth limit in java.xml is set by jdk.xml.maxElementDepth system property.
Default value was changed from 0 (non-limit) to 100 since jdk-19+16
So, in recent Java versions, the second path is triggered, however the check of the exception object is incorrect.

Original SAXParseException with specific text is wrapped into XMLParserException with a different message at XMLParserImpl:73

throw new XMLParserException(ex, "empty", new Object[] {"Error parsing the inputstream"});

So the test needs to check the type and the message of the cause exception.

@coheigea coheigea merged commit c226aae into apache:main Jun 5, 2026
3 checks passed
@kuzjka
Copy link
Copy Markdown
Contributor Author

kuzjka commented Jun 5, 2026

Default value was changed from 0 (non-limit) to 100 since jdk-19+16

Oops, confused with another pull request. The change in OpenJDK was introduced in jdk-24+26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants