The RepositoryChunk::finalize() method has been kept since the inception of JFR, before try-with-resources (JDK 7) and Cleaner (JDK 9) existed. The method should be removed now that finalization is deprecated for removal.
RepositoryChunks are reference counted and when a recording is closed, chunks that are not referenced by a recording are removed from the disk repository. Users can get a listing of not closed recordings by invoking FlightRecorder::getRecordings() so they own the lifecycle already. If a user forget to close a recording, the data will be kept in the repository.
ChunkInputStream och ChunkChannel have finalize() methods and increases the reference counter when copying data out from the disk repository. If an IOException happens during file reading, they are closed and the reference counter decreased for the remaining chunks. Finalizers are not needed.
RepositoryChunks are reference counted and when a recording is closed, chunks that are not referenced by a recording are removed from the disk repository. Users can get a listing of not closed recordings by invoking FlightRecorder::getRecordings() so they own the lifecycle already. If a user forget to close a recording, the data will be kept in the repository.
ChunkInputStream och ChunkChannel have finalize() methods and increases the reference counter when copying data out from the disk repository. If an IOException happens during file reading, they are closed and the reference counter decreased for the remaining chunks. Finalizers are not needed.
- relates to
-
JDK-8253568 Replace and mitigate Object.finalize() uses in JDK libraries
-
- Open
-