lxcxjxhx opened a new pull request, #16401:
URL: https://github.com/apache/dubbo/pull/16401
## 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.
```java
// Before: FileInputStream is not closed on exception path
return readLines(new FileInputStream(file));
```
```java
// After: try-with-resources ensures the stream is always closed
try (InputStream is = new FileInputStream(file)) {
return readLines(is);
}
```
## Checklist
- [x] I have read and followed the [contributing
guidelines](https://github.com/apache/dubbo/blob/3.3/CONTRIBUTING.md)
- [x] This change is focused on a single issue (resource leak in
`IOUtils.readLines(File)`)
- [x] I have verified this does not conflict with existing PR #15874, which
fixes `read(InputStream, String)` but not `readLines(File)`
## 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]