CAMEL-24046 - avoid system property leak to other tests from ZXsltTotalOpsTest#24955
CAMEL-24046 - avoid system property leak to other tests from ZXsltTotalOpsTest#24955apupier wants to merge 1 commit into
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Good, pragmatic approach to reducing the flakiness of XsltFromFileExceptionTest.
What works well:
- The dedicated XSL file (
example-file-exception-test.xsl) isolates this test from the ~16 other tests that referenceexample.xsl, eliminating potential resource contention through JAXP'sTransformerFactorycaching layer - The new file is an exact copy of
example.xsl— no behavioral change to the test logic - The PR description is honest about scope: this targets the 2nd/3rd retry failures (the
JAXP0801003operator-limit error), not necessarily the first failure mode
Minor observation (non-blocking): The JAXP0801003 error about XPath operator limits (accumulated '2' operators exceeds the '1' limit set by 'system property') could also stem from another test setting jdk.xml.xpathExprOpLimit via System.setProperty without restoring it. File isolation helps with TransformerFactory cache contention but wouldn't fix a JVM-wide system property leak. Worth investigating separately if the flakiness persists after this change.
Overall, a sensible incremental fix — reduces the blast radius without over-engineering it. 👍
Claude Code on behalf of gnodet — AI-generated review
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 23 tested, 0 compile-only — current: 0 all testedMaveniverse Scalpel detected 23 affected modules (current approach: 0).
|
gnodet
left a comment
There was a problem hiding this comment.
Updating my earlier review after investigating the root cause of the flakiness.
Root cause: system property leak from ZXsltTotalOpsTest
The JAXP error in the 2nd/3rd retries —
JAXP0801003: the compiler encountered XPath expressions with an accumulated '2'
operators that exceeds the '1' limit set by 'system property'.
— is caused by ZXsltTotalOpsTest (same package) leaking jdk.xml.xpathTotalOpLimit=1 via System.setProperty.
Here's the chain:
ZXsltTotalOpsTestcallsxslt.setXpathTotalOpLimit(1), which triggersSystem.setProperty("jdk.xml.xpathTotalOpLimit", "1")duringXsltComponent.doInit()- The test expects
context.start()to throw (the XSL has 2 operators > limit of 1) - Cleanup relies on
XsltComponent.doShutdown()callingSystem.clearProperty()— but whencontext.start()fails mid-way, the shutdown path may not fully execute - When
XsltFromFileExceptionTestretries (after its 1st failure for a different reason), the leaked property causes any XSL compilation with >1 operator to fail
This matches your observation exactly: the 1st failure has a different cause, then ZXsltTotalOpsTest runs during the retry window, leaks the property, and retries 2 and 3 hit the JAXP limit.
Why a dedicated XSL file won't fix this
The new example-file-exception-test.xsl has 2 XPath operators (match="/" + select="/hello") — identical to example.xsl. When jdk.xml.xpathTotalOpLimit=1 is leaked, any XSL file with >1 operator fails regardless of its path. File isolation addresses TransformerFactory cache contention, but the error is a JVM-wide system property issue.
Suggested fix
Ensure ZXsltTotalOpsTest cleans up the system property reliably, similar to how XPathFeatureTest handles it (with @ResourceLock(Resources.SYSTEM_PROPERTIES) + try/finally):
@Isolated
@ResourceLock(Resources.SYSTEM_PROPERTIES)
public class ZXsltTotalOpsTest extends ContextTestSupport {
@AfterEach
void clearXpathLimit() {
System.clearProperty("jdk.xml.xpathTotalOpLimit");
}
// ... rest unchanged
}Adding @AfterEach guarantees the property is cleared even when context.start() throws and the CamelContext lifecycle doesn't fully unwind. The @ResourceLock annotation prevents other system-property-sensitive tests from running concurrently.
Claude Code on behalf of gnodet — AI-generated review
|
the 2nd and 3rd failure are occuring after [INFO] Running org.apache.camel.component.xslt.ZXsltTotalOpsTest but the test is in success and it is significantly after, so it sounds like there is a bug that doesn't set back the property |
|
reported https://issues.apache.org/jira/browse/CAMEL-24216 to fix the spotted issue correctly and wil provide the workaround by unsetting the system property in tear down |
5430ded to
1cd0c36
Compare
1cd0c36 to
d8e87d8
Compare
ZXsltTotalOpsTest due to https://issues.apache.org/jira/browse/CAMEL-24216 , a system property is leaking to other tests. it can impact other tests to fail when they are played after it. For instance when XsltFromFileExceptionTest is flaky, the 2nd and 3rd run are launched after it and are failing. Signed-off-by: Aurélien Pupier <apupier@ibm.com>
d8e87d8 to
b7f4acd
Compare
when it is failing, usually the 2nd and 3rd run are failing with:
When I checked on the workspace filesystem of a failed build the file camel-core/target/test-classes/org/apache/camel/component/xslt/example.xsl seems fine.
But maybe the file is locked at that time or modified temporarily by another test, so modified the test to use a specific xsl file for this test class.
Note that it doesn't impact the first flaky failure which is usually another error.
I propose to first try this way to see if we can get rid of the 2nd and 3rd failure, which are causing the build to fail. if there is only the first attempt failing, it is not nice but only flaky and few seconds are lost.
Description
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.