src.it.unimi.dsi.io.SafelyCloseable Maven / Gradle / Ivy
package it.unimi.dsi.io;
/*
* DSI utilities
*
* Copyright (C) 2006-2017 Sebastiano Vigna
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see .
*
*/
import 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 own {@link java.io.Closeable#close()} method
* to let the abstract class track correctly the resource. Moreover,
* they must run super.finalize()
in
* their own finaliser (if any), as finalisation chaining is not automatic.
*
*
Note that if a concrete subclass implements readResolve()
, it must
* call super.close()
, or actually return this
(i.e., the deserialised
* instance); otherwise, a spurious log could be generated when the deserialised instance is collected.
*
* @author Sebastiano Vigna
* @since 1.1
*/
public interface SafelyCloseable extends Closeable {}