ReleasableInputStream extends InputStream { @Override public long skip(long l) throws IOException { try { return delegate.skip(l); } catch (IOException e) { safeClose(); throw e; } } ReleasableInputStream(InputStream delegate, Runnable onClose); @Override int read(); @Override int read(byte[] bytes); @Override int read(byte[] bytes, int i, int i1); @Override long skip(long l); @Override int available(); @Override void close(); @Override void mark(int i); @Override void reset(); @Override boolean markSupported();  }
@Test public void skip() throws Exception { releasableInputStream.skip(100); assertFalse(wasCalled.get()); }
@Test(expected = IOException.class) public void failedSkip() throws Exception { failedReleasableInputStream.skip(100); assertTrue(wasCalled.get()); }