jenkinsci / lib-file-leak-detector

Java agent that detects file handle leak
http://file-leak-detector.kohsuke.org/
MIT License
241 stars 112 forks source link

Support files opened via `Files#newBufferedWriter` #161

Closed adangel closed 7 months ago

adangel commented 11 months ago

I noticed, that files opened via Files.newBufferedWriter were not tracked. This is added now - using sun.nio.ch.FileChannelImpl - the close of the file was already recognized, as internally the file is handled as a FileChannel.

Testing done

Test added in FileDemo. Also added a test for Files.newBufferedReader - but that already worked.

Locally tested with java 11, 17, 21 (mvn clean integration-test)

### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue