[#16098] Fix resource leaks and improve code quality in ConfigUtils#16097
[#16098] Fix resource leaks and improve code quality in ConfigUtils#16097DocJlm wants to merge 2 commits intoapache:3.3from
Conversation
- Replace StringBuffer with StringBuilder in replaceProperty() method for better performance (no thread-safety needed for local variable) - Refactor loadProperties() to use try-with-resources for FileInputStream, eliminating manual close() calls and potential resource leaks - Refactor multi-file loading loop to use try-with-resources for InputStream from URL, removing empty catch blocks - Fix resource leak in loadMigrationRule() where InputStream from URL was never closed after reading
…Buffer for Java 8 compatibility
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16097 +/- ##
============================================
- Coverage 60.80% 60.80% -0.01%
- Complexity 11750 11753 +3
============================================
Files 1953 1953
Lines 89121 89118 -3
Branches 13443 13444 +1
============================================
- Hits 54192 54189 -3
+ Misses 29369 29367 -2
- Partials 5560 5562 +2
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:
|
|
Hi @DocJlm , I think the code is already implementing the "StringBuffer"? |
Hi @LI123456mo, yes, you're right. I initially changed |
If it is java 8 you are right to implement "StringBuffer" |
What is the purpose of the change?
Fix resource leaks and improve code quality in
ConfigUtils(dubbo-commonmodule). Fixes #16098.loadProperties()to use try-with-resources forFileInputStream, eliminating manual close() calls and potential resource leaksInputStreamfrom URL, removing empty catch blocksloadMigrationRule()whereInputStreamfrom URL was never closed after readingThe most critical fix is in
loadMigrationRule()where anInputStreamopened viaurl.openStream()is never closed, which can lead to file handle leaks in long-running applications.Checklist