RFR: 8364427: JFR: Possible resource leak in Recording::getStream
Erik Gahlin
egahlin at openjdk.org
Thu Jul 31 13:39:53 UTC 2025
On Thu, 31 Jul 2025 13:13:53 GMT, Francesco Andreuzzi <duke at openjdk.org> wrote:
>> Could you elaborate?
>>
>> There is the 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?
I think it's closed by the read methods or close(). Just to be sure, I inserted:
+ if (this.stream != null) {
+ throw new InternalError("Should not happen");
+ }
stream = new BufferedInputStream(Files.newInputStream(currentChunk.getFile()));
and ran all the tests without failure.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26575#discussion_r2245424612
More information about the hotspot-jfr-dev
mailing list