Skip to content

Conversation

@paxxie2
Copy link
Contributor

@paxxie2 paxxie2 commented May 8, 2025

fix issue #15355

What is the purpose of the change?

Correctly close BZip2CompressorOutputStream using try with sources

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?

@paxxie2 paxxie2 changed the title fix: Fix the issue of triple bzip2 compressor close ByteArrayOutputStream #15355 fix: Fix the issue of triple bzip2 compressor close ByteArrayOutputStream May 8, 2025
@codecov-commenter
Copy link

codecov-commenter commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.74%. Comparing base (c778473) to head (6d76ecc).
Report is 77 commits behind head on 3.3.

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15356      +/-   ##
============================================
- Coverage     60.77%   60.74%   -0.03%     
+ Complexity    10920    10913       -7     
============================================
  Files          1886     1886              
  Lines         86122    86144      +22     
  Branches      12902    12906       +4     
============================================
- Hits          52337    52331       -6     
- Misses        28331    28350      +19     
- Partials       5454     5463       +9     
Flag Coverage Δ
integration-tests 33.12% <0.00%> (-0.08%) ⬇️
samples-tests 29.35% <0.00%> (+0.01%) ⬆️
unit-tests 58.87% <100.00%> (-0.04%) ⬇️

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.

BZip2CompressorOutputStream cos;
try {
cos = new BZip2CompressorOutputStream(out);
try (BZip2CompressorOutputStream cos = new BZip2CompressorOutputStream(out)) {
Copy link
Member

@mytang0 mytang0 May 8, 2025

Choose a reason for hiding this comment

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

'Out' should also be fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a FilterOutputStream, the underlying output stream should be closed together with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

commons-io ByteArrayOutputStream directly operates on memory, not network IO, and does not manipulate file handles, it's close() method is also an empty implementation, and it is not necessary to close。Just like a regular Java object.
org.apache.commons.io.output.ByteArrayOutputStream#close:

 public void close() throws IOException {
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

So I think we needn't do any change.

@zrlw zrlw closed this Jun 19, 2025
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.

5 participants