RFR: 8364427: JFR: Possible resource leak in Recording::getStream

Francesco Andreuzzi duke at openjdk.org
Thu Jul 31 13:16:54 UTC 2025


On Thu, 31 Jul 2025 13:05:58 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:

>> src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java line 69:
>> 
>>> 67:         while (nextChunk()) {
>>> 68:             try {
>>> 69:                 stream = new BufferedInputStream(Files.newInputStream(currentChunk.getFile()));
>> 
>> Should we close `stream` if it's not null?
>
> Could you elaborate? 
> 
> There is closeStream method that is called when there is no more data to be read.

If `nextChunk` returns `true` e.g. 2 times in a row, the second iteration of the while loop at L67 will overwrite `stream` without closing the previous instance. I don't see if/where `closeStream` will be called within two iterations of the loop, maybe I'm missing something?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26575#discussion_r2245367507


More information about the hotspot-jfr-dev mailing list