daguimu opened a new issue, #10218: URL: https://github.com/apache/rocketmq/issues/10218
### Before Creating the Bug Report - [x] I found a bug, not just asking a question, which should be created in [GitHub Discussions](https://github.com/apache/rocketmq/discussions). - [x] I have searched the [GitHub Issues](https://github.com/apache/rocketmq/issues) and [GitHub Discussions](https://github.com/apache/rocketmq/discussions) of this repository and believe that this is not a duplicate. - [x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ. ### Runtime platform environment All platforms ### RocketMQ version develop branch (latest) ### JDK Version JDK 8+ ### Describe the Bug In `DumpCompactionLogCommand.java`, a `RandomAccessFile` is created to obtain a `FileChannel`, but neither the `RandomAccessFile` nor the `FileChannel` is ever closed: ```java FileChannel fileChannel = new RandomAccessFile(fileName, "rw").getChannel(); ByteBuffer buf = fileChannel.map(MapMode.READ_WRITE, 0, fileSize); // ... use buf ... UtilAll.cleanBuffer(buf); // fileChannel and RandomAccessFile are never closed ``` The anonymous `RandomAccessFile` instance is immediately discarded after calling `.getChannel()`, making it impossible to close later. The `FileChannel` obtained from it is also never closed. This leaks file descriptors. ### Steps to Reproduce Run the `DumpCompactionLogCommand` tool to dump a compaction log file. After execution, the file descriptor remains open. ### What Did You Expect to See? The `RandomAccessFile` and `FileChannel` should be properly closed after use, ideally using try-with-resources. ### What Did You See Instead? File descriptors are leaked because neither resource is closed. ### Additional Context The fix should use try-with-resources to ensure both the `RandomAccessFile` and `FileChannel` are properly closed. -- 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]
