Skip to content

fix(common): close input stream in ConfigUtils#loadProperties fallback#16116

Open
LouisLau-art wants to merge 1 commit intoapache:3.3from
LouisLau-art:fix/configutils-close-stream-16098
Open

fix(common): close input stream in ConfigUtils#loadProperties fallback#16116
LouisLau-art wants to merge 1 commit intoapache:3.3from
LouisLau-art:fix/configutils-close-stream-16098

Conversation

@LouisLau-art
Copy link

What

Fixes an input stream resource leak in ConfigUtils.loadProperties(...) when allowMultiFile == false and fallback loading path is used.

Previously the code called:

  • properties.load(ClassUtils.getClassLoader().getResourceAsStream(fileName));

This could leave the stream unclosed. The fallback now uses try-with-resources and null-checks the stream before loading.

Why

This addresses issue #16098 and keeps resource handling consistent with other load paths in ConfigUtils.

Verification

  • ./mvnw -pl dubbo-common -Dtest=ConfigUtilsTest test -DskipITs
  • Result: BUILD SUCCESS (Tests run: 25, Failures: 0, Errors: 0, Skipped: 1)

Fixes #16098

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.79%. Comparing base (2c49565) to head (7a1e4d2).
⚠️ Report is 6 commits behind head on 3.3.

Files with missing lines Patch % Lines
...ava/org/apache/dubbo/common/utils/ConfigUtils.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16116      +/-   ##
============================================
- Coverage     60.80%   60.79%   -0.01%     
+ Complexity    11753    11751       -2     
============================================
  Files          1953     1953              
  Lines         89118    89120       +2     
  Branches      13444    13445       +1     
============================================
- Hits          54187    54184       -3     
+ Misses        29367    29366       -1     
- Partials       5564     5570       +6     
Flag Coverage Δ
integration-tests-java21 32.25% <66.66%> (+0.08%) ⬆️
integration-tests-java8 32.23% <66.66%> (+<0.01%) ⬆️
samples-tests-java21 32.12% <66.66%> (-0.03%) ⬇️
samples-tests-java8 29.70% <66.66%> (-0.01%) ⬇️
unit-tests-java11 59.03% <66.66%> (-0.01%) ⬇️
unit-tests-java17 ?
unit-tests-java21 58.57% <66.66%> (+0.03%) ⬆️
unit-tests-java25 58.48% <66.66%> (-0.01%) ⬇️
unit-tests-java8 59.05% <66.66%> (+<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.

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] Fix resource leaks and improve code quality in ConfigUtils

2 participants