Skip to content

fix: resolve FileInputStream resource leak in IOUtils.readLines(File) - #16401

Closed
lxcxjxhx wants to merge 1 commit into
apache:3.3from
lxcxjxhx:fix/ioutils-readlines-resource-leak
Closed

fix: resolve FileInputStream resource leak in IOUtils.readLines(File)#16401
lxcxjxhx wants to merge 1 commit into
apache:3.3from
lxcxjxhx:fix/ioutils-readlines-resource-leak

Conversation

@lxcxjxhx

Copy link
Copy Markdown

What is the purpose of the change?

Fix a FileInputStream resource leak in IOUtils.readLines(File).

What does this PR fix?

In IOUtils.readLines(File file), a FileInputStream is created inline and passed to readLines(InputStream). If an exception occurs during reading, the underlying file handle is never closed, leading to a file descriptor leak.

// Before: FileInputStream is not closed on exception path
return readLines(new FileInputStream(file));
// After: try-with-resources ensures the stream is always closed
try (InputStream is = new FileInputStream(file)) {
    return readLines(is);
}

Checklist

Note

Apologies for any inconvenience. Due to local environment limitations (Windows without full JDK/Maven setup for Dubbo), I am relying on CI/CD for automated testing.

Use try-with-resources to ensure FileInputStream is properly closed in IOUtils.readLines(File) method, preventing potential file handle leaks.
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.67%. Comparing base (3a30432) to head (7e79efc).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16401      +/-   ##
============================================
- Coverage     60.87%   60.67%   -0.21%     
+ Complexity    11766    11218     -548     
============================================
  Files          1953     1953              
  Lines         89273    89274       +1     
  Branches      13473    13473              
============================================
- Hits          54346    54165     -181     
- Misses        29333    29480     +147     
- Partials       5594     5629      +35     
Flag Coverage Δ
integration-tests-java21 32.14% <0.00%> (+<0.01%) ⬆️
integration-tests-java8 32.24% <0.00%> (+0.02%) ⬆️
samples-tests-java21 ?
samples-tests-java8 29.69% <0.00%> (-0.10%) ⬇️
unit-tests-java11 59.13% <100.00%> (+0.01%) ⬆️
unit-tests-java17 ?
unit-tests-java21 58.64% <100.00%> (+0.03%) ⬆️
unit-tests-java25 58.56% <100.00%> (-0.01%) ⬇️
unit-tests-java8 59.15% <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 Harness.
📢 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 commented Jul 29, 2026

Copy link
Copy Markdown
Member

This change serves no purpose because the underlying stream is already closed internally.

@RainYuY RainYuY closed this Jul 29, 2026
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.

3 participants