@Test public void readWithBytesResumesWithRuntimeException() throws Exception { TestingInputStream next = new TestingInputStream( RUNTIME_EXCEPTION, RUNTIME_EXCEPTION, RUNTIME_EXCEPTION, RUNTIME_EXCEPTION, RUNTIME_EXCEPTION, 1, IO_EXCEPTION, 2, -1); SimpleReopener reopener = new SimpleReopener(next); ResumableInputStream in = new ResumableInputStream(next, reopener); assertThat(in.read(new byte[1]), is(1)); assertThat(reopener.getLastOffset(), is(0L)); assertThat(reopener.getLastClosedCause(), instanceOf(RuntimeException.class)); assertThat(reopener.getReopenCount(), is(5)); assertThat(in.read(new byte[1]), is(2)); assertThat(reopener.getLastOffset(), is(1L)); assertThat(reopener.getReopenCount(), is(6)); assertThat(reopener.getLastClosedCause(), instanceOf(IOException.class)); assertThat(in.read(new byte[1]), is(-1)); assertThat(reopener.getLastOffset(), is(1L)); assertThat(reopener.getReopenCount(), is(6)); }
@Override public int read() throws IOException { while (true) { try { int v = in.read(); if (v >= 0) { offset += 1; } return v; } catch (IOException | RuntimeException ex) { reopen(ex); } } }
ResumableInputStream extends InputStream { @Override public int read() throws IOException { while (true) { try { int v = in.read(); if (v >= 0) { offset += 1; } return v; } catch (IOException | RuntimeException ex) { reopen(ex); } } } }
ResumableInputStream extends InputStream { @Override public int read() throws IOException { while (true) { try { int v = in.read(); if (v >= 0) { offset += 1; } return v; } catch (IOException | RuntimeException ex) { reopen(ex); } } } ResumableInputStream(InputStream initialInputStream, Reopener reopener);  ResumableInputStream(Reopener reopener); }
ResumableInputStream extends InputStream { @Override public int read() throws IOException { while (true) { try { int v = in.read(); if (v >= 0) { offset += 1; } return v; } catch (IOException | RuntimeException ex) { reopen(ex); } } } ResumableInputStream(InputStream initialInputStream, Reopener reopener);  ResumableInputStream(Reopener reopener); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override int available(); @Override void close(); }
ResumableInputStream extends InputStream { @Override public int read() throws IOException { while (true) { try { int v = in.read(); if (v >= 0) { offset += 1; } return v; } catch (IOException | RuntimeException ex) { reopen(ex); } } } ResumableInputStream(InputStream initialInputStream, Reopener reopener);  ResumableInputStream(Reopener reopener); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override long skip(long n); @Override int available(); @Override void close();  }