Package it.unimi.dsi.io
Interface SafelyCloseable
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
FileLinesByteArrayCollection.FileLinesIterator
,FileLinesByteArrayIterable.FileLinesIterator
,FileLinesCollection.FileLinesIterator
,FileLinesCollection.FileLinesIterator
,FileLinesMutableStringIterable.FileLinesIterator
,OfflineIterable
,OfflineIterable.OfflineIterator
public interface SafelyCloseable extends java.io.Closeable
A marker interface for a closeable resource that implements safety measures to make resource tracking easier.Classes implementing this interface must provide a safety-net finaliser—a finaliser that closes the resource and logs that resource should have been closed.
When the implementing class is abstract, concrete subclasses must call
super.close()
in their ownCloseable.close()
method to let the abstract class track correctly the resource. Moreover, they must runsuper.finalize()
in their own finaliser (if any), as finalisation chaining is not automatic.Note that if a concrete subclass implements
readResolve()
, it must callsuper.close()
, or actually returnthis
(i.e., the deserialised instance); otherwise, a spurious log could be generated when the deserialised instance is collected.- Since:
- 1.1
- Author:
- Sebastiano Vigna