-
Notifications
You must be signed in to change notification settings - Fork 26.5k
fix some resource leak #15743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.3
Are you sure you want to change the base?
fix some resource leak #15743
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15743 +/- ##
============================================
Coverage 60.75% 60.75%
- Complexity 15 11731 +11716
============================================
Files 1938 1938
Lines 88627 88624 -3
Branches 13381 13380 -1
============================================
+ Hits 53842 53843 +1
+ Misses 29255 29251 -4
Partials 5530 5530
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:
|
There was a problem hiding this 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 refactors resource management code to use try-with-resources statements for automatic resource cleanup, improving code quality and preventing potential resource leaks.
- Converted manual close() calls to try-with-resources in compression utilities
- Removed redundant close() calls that are now handled automatically
- Improved code clarity by reducing boilerplate resource management code
Reviewed Changes
Copilot reviewed 2 out of 2 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 | Refactored both compress() and decompress() methods to use try-with-resources for BZip2 streams |
| dubbo-plugin/dubbo-security/src/main/java/org/apache/dubbo/security/cert/DubboCertManager.java | Converted JcaPEMWriter usage to try-with-resources and removed manual close() calls |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| StringWriter str = new StringWriter(); | ||
| JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(str); | ||
| jcaPEMWriter.writeObject(pemObject); | ||
| jcaPEMWriter.close(); | ||
| str.close(); | ||
| try (JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(str)) { | ||
| jcaPEMWriter.writeObject(pemObject); | ||
| } | ||
| return str.toString(); |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The StringWriter should be included in the try-with-resources statement to ensure it is properly closed. While StringWriter.close() doesn't throw exceptions or manage external resources, following the pattern consistently ensures best practices.
What is the purpose of the change?
Fix #15742
Found some resources that were not properly handled or closed.
Fixed them by using try-with-resources
Checklist