Skip to content

fix: resolve resource leaks using try-with-resources#15874

Open
heliang666s wants to merge 11 commits intoapache:3.3from
heliang666s:fix-resource-leaks
Open

fix: resolve resource leaks using try-with-resources#15874
heliang666s wants to merge 11 commits intoapache:3.3from
heliang666s:fix-resource-leaks

Conversation

@heliang666s
Copy link
Member

What is the purpose of the change?

fix: resolve resource leaks using try-with-resources #15742

@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.80%. Comparing base (678d2a7) to head (d7d07a4).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15874      +/-   ##
============================================
+ Coverage     60.74%   60.80%   +0.06%     
- Complexity    11751    11756       +5     
============================================
  Files          1953     1953              
  Lines         89120    89110      -10     
  Branches      13443    13443              
============================================
+ Hits          54132    54182      +50     
+ Misses        29420    29361      -59     
+ Partials       5568     5567       -1     
Flag Coverage Δ
integration-tests-java21 32.18% <0.00%> (+0.06%) ⬆️
integration-tests-java8 32.33% <0.00%> (+0.07%) ⬆️
samples-tests-java21 32.17% <0.00%> (+<0.01%) ⬆️
samples-tests-java8 29.74% <0.00%> (+0.02%) ⬆️
unit-tests-java11 59.08% <77.77%> (+0.08%) ⬆️
unit-tests-java17 58.54% <100.00%> (+0.06%) ⬆️
unit-tests-java21 58.55% <100.00%> (+0.06%) ⬆️
unit-tests-java25 58.51% <100.00%> (+0.04%) ⬆️
unit-tests-java8 59.07% <77.77%> (+0.09%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

RainYuY
RainYuY previously approved these changes Dec 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses resource-leak risks by converting manual stream/writer management to Java try-with-resources across a few utility and protocol components.

Changes:

  • Update Triple Bzip2 compressor/decompressor to use try-with-resources for stream handling.
  • Update Dubbo certificate PEM generation to use try-with-resources for writer handling.
  • Update common IO and byte utilities to use try-with-resources for reader/stream handling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/compressor/Bzip2.java Ensures BZip2 streams are reliably closed during compress/decompress.
dubbo-plugin/dubbo-security/src/main/java/org/apache/dubbo/security/cert/DubboCertManager.java Switches PEM writer lifecycle to try-with-resources to avoid leaks.
dubbo-common/src/main/java/org/apache/dubbo/common/utils/IOUtils.java Uses try-with-resources for InputStreamReader in read(InputStream, String).
dubbo-common/src/main/java/org/apache/dubbo/common/io/Bytes.java Uses try-with-resources for deflate/inflate streams to ensure cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@zrlw zrlw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@heliang666s heliang666s requested a review from RainYuY February 6, 2026 12:19
@heliang666s
Copy link
Member Author

@RainYuY please review again!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants