class ReleasableInputStream extends InputStream {

    @Override
    public void reset() throws IOException {
        try {
            delegate.reset();
        } catch (IOException e) {
            safeClose();
            throw e;
        }
    }

    public  ReleasableInputStream(InputStream delegate, Runnable onClose);

}