Skip to content

Fix Windows CI failures: close TLS cert streams and stop leaking metrics system properties in tests - #16615

Closed
EarthChen wants to merge 2 commits into
3.3from
fix/ci-test-flaky
Closed

EarthChen wants to merge 2 commits into
3.3from
fix/ci-test-flaky

Conversation

@EarthChen

Copy link
Copy Markdown
Member

Summary

Fixes the two persistent unit-test failures on the 3.3 branch CI (Windows jobs red since #16590, SpringBootConfigMetricsTest failing intermittently on ubuntu):

SSLConfigCertProvider.getConsumerConnectionConfig()
- IOUtils.toByteArray(sslConfig.getClientKeyCertChainPathStream())
+ readAll(sslConfig.getClientKeyCertChainPathStream())   # try-with-resources
  1. SSLConfigCertProvider leaked one FileInputStream per certificate file on every TLS connection. IOUtils.toByteArray(InputStream) does not close its input. On Linux/macOS deleting an open file succeeds, but on Windows the open handle blocks deletion of the JUnit @TempDir, so ClientTlsHostnameVerificationTest (introduced by Pass the peer address to the TCP TLS client engine #16590) errored with Failed to close extension context ... ca.pem, client.key, client.pem — exactly the three files this provider reads. The leaked files list matches the streams opened here one-to-one; the server-side SslContextBuilder.forServer(File, File) reads (closed by Netty) never appeared in the failure. This is also a production fd leak (one per cert per connection attempt).

  2. AnnotationIsolationTest set dubbo.metrics.protocol=disabled via SysProps and never cleaned it up. Dubbo resolves dubbo.metrics.* from system properties with the highest precedence, so any later test class in the same JVM failed. SpringBootConfigMetricsTest died with expected: <prometheus> but was: <disabled>. fix: make SpringBootConfigPropsTest immune to leaked metrics System properties #16420 already added the System.clearProperty guard to SpringBootConfigPropsTest; this adds the same guard to SpringBootConfigMetricsTest and removes the leak source in AnnotationIsolationTest (@AfterEach).

The Samples Test Build test image failures seen on the same runs are unrelated: the nacos-mysql sample Dockerfile hit a transient HTTP 503 pulling mysql-schema.sql from GitHub.

Evidence

Reproduced locally on 3.3 (macOS, JDK 17) by injecting the leaked property, mirroring the CI failure mechanism:

# before
$ ./mvnw -pl dubbo-config/dubbo-config-spring -am test -Dtest=SpringBootConfigMetricsTest -Ddubbo.metrics.protocol=disabled
SpringBootConfigMetricsTest.testMetrics:78 expected: <prometheus> but was: <disabled>
BUILD FAILURE

# after (same command)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Full regression on the touched module (matches the CI test count):

$ ./mvnw -pl dubbo-config/dubbo-config-spring test
Tests run: 147, Failures: 0, Errors: 0, Skipped: 30
BUILD SUCCESS
$ ./mvnw -pl dubbo-remoting/dubbo-remoting-netty4 -am test -Dtest=ClientTlsHostnameVerificationTest,SSLConfigCertProviderTest
Tests run: 6/6 + 3/3, Failures: 0, Errors: 0
BUILD SUCCESS

Note: the Windows-only @TempDir deletion failure cannot be reproduced on macOS (Linux/macOS allow deleting open files); the fix closes the exact handles the CI stack trace reported as undeletable. The Windows CI legs are the final verifier.

Merge Danger

Door: two-way

Blast Radius: small — closing streams that are already fully consumed (read to byte[]) before use; no behavior change on Linux/macOS, removes a production fd leak on all platforms. Test-only changes besides SSLConfigCertProvider.

Made with Cursor

The streams returned by SslConfig.getXxxPathStream() are file-backed and
IOUtils.toByteArray() does not close them. Every TLS connection therefore
leaked one FileInputStream per certificate file. On Windows an open handle
blocks deletion of the file, which made JUnit @tempdir cleanup fail in
ClientTlsHostnameVerificationTest and broke the Windows CI jobs
(see #16590's follow-up).

Signed-off-by: earthchen <earthchen@apache.org>
…st classes

AnnotationIsolationTest set dubbo.metrics.protocol=disabled via SysProps
and never cleared it. Dubbo resolves dubbo.metrics.* from system
properties with the highest precedence, so any later test class in the
same JVM (e.g. SpringBootConfigMetricsTest) failed with 'expected
<prometheus> but was <disabled>'.

- clear the properties in AnnotationIsolationTest's @AfterEach
- guard SpringBootConfigMetricsTest the same way SpringBootConfigPropsTest
  already does since #16420

Signed-off-by: earthchen <earthchen@apache.org>
@EarthChen

Copy link
Copy Markdown
Member Author

Closing: reopening from my fork per contribution workflow.

@EarthChen EarthChen closed this Nov 28, 2026
@EarthChen
EarthChen deleted the fix/ci-test-flaky branch November 28, 2026 03:51
@codecov-commenter

codecov-commenter commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.24%. Comparing base (b364f64) to head (0c91042).

Additional details and impacted files
@@              Coverage Diff              @@
##                3.3   #16615       +/-   ##
=============================================
+ Coverage     36.89%   61.24%   +24.34%     
- Complexity    11753    11768       +15     
=============================================
  Files          1952     1953        +1     
  Lines         89387    89411       +24     
  Branches      13420    13502       +82     
=============================================
+ Hits          32983    54757    +21774     
+ Misses        51800    29034    -22766     
- Partials       4604     5620     +1016     
Flag Coverage Δ
integration-tests-java21 32.07% <0.00%> (-0.03%) ⬇️
integration-tests-java8 32.29% <0.00%> (+0.08%) ⬆️
samples-tests-java21 32.07% <0.00%> (+0.02%) ⬆️
samples-tests-java8 29.68% <0.00%> (-0.01%) ⬇️
unit-tests-java11 59.55% <100.00%> (?)
unit-tests-java17 58.98% <100.00%> (?)
unit-tests-java21 59.02% <100.00%> (?)
unit-tests-java25 58.98% <100.00%> (?)
unit-tests-java8 59.52% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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