fix: resolve resource leaks using try-with-resources#15874
Open
heliang666s wants to merge 10 commits intoapache:3.3from
Open
fix: resolve resource leaks using try-with-resources#15874heliang666s wants to merge 10 commits intoapache:3.3from
heliang666s wants to merge 10 commits intoapache:3.3from
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15874 +/- ##
=========================================
Coverage 60.75% 60.76%
+ Complexity 11757 11755 -2
=========================================
Files 1952 1952
Lines 89012 89002 -10
Branches 13421 13421
=========================================
+ Hits 54079 54080 +1
+ Misses 29367 29349 -18
- Partials 5566 5573 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
RainYuY
requested changes
Dec 16, 2025
RainYuY
previously approved these changes
Dec 16, 2025
zrlw
reviewed
Dec 18, 2025
...o-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/compressor/Bzip2.java
Outdated
Show resolved
Hide resolved
Update Bzip2.compress() and Bytes.zip() to follow PMC requirements
b410dfe to
936ea58
Compare
Contributor
There was a problem hiding this comment.
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.
dubbo-plugin/dubbo-security/src/main/java/org/apache/dubbo/security/cert/DubboCertManager.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change?
fix: resolve resource leaks using try-with-resources #15742