Skip to content

Conversation

@AROP-REPLICATION
Copy link
Contributor

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

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.75%. Comparing base (aed93d5) to head (6798384).

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              
Flag Coverage Δ
integration-tests-java21 32.32% <0.00%> (+0.01%) ⬆️
integration-tests-java8 32.53% <0.00%> (+<0.01%) ⬆️
samples-tests-java21 32.10% <0.00%> (+0.03%) ⬆️
samples-tests-java8 29.84% <0.00%> (+0.03%) ⬆️
unit-tests-java11 59.02% <100.00%> (-0.03%) ⬇️
unit-tests-java17 58.50% <100.00%> (-0.03%) ⬇️
unit-tests-java21 58.51% <100.00%> (-0.02%) ⬇️
unit-tests-java8 59.01% <100.00%> (+0.01%) ⬆️

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.

@zrlw zrlw requested review from Copilot and zrlw November 4, 2025 02:35
Copy link

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 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.

Comment on lines 370 to 374
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();
Copy link

Copilot AI Nov 4, 2025

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.

Copilot uses AI. Check for mistakes.
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.

[Bug] Found some resources seem not handled properly

2 participants