ReleasableInputStream extends InputStream { @Override public void mark(int i) { try { delegate.mark(i); } catch (RuntimeException 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 mark() throws Exception { releasableInputStream.mark(0); assertFalse(wasCalled.get()); }
@Test(expected = RuntimeException.class) public void failedMark() throws Exception { failedReleasableInputStream.mark(0); assertTrue(wasCalled.get()); }