@Test public void testIOExceptionWhenOnDiskBufferingWithBrokenSource() throws IOException { InputStream brokenInputStream = mock(InputStream.class); doThrow(IOException.class).when(brokenInputStream).read(); doThrow(IOException.class).when(brokenInputStream).read(any()); doThrow(IOException.class).when(brokenInputStream).read(any(), anyInt(), anyInt()); doThrow(IOException.class).when(brokenInputStream).close(); InputStream sourceInputStream = new SequenceInputStream( new NullInputStream(100), brokenInputStream ); assertThatThrownBy(() -> new DeferredFileBufferingInputStream(sourceInputStream, 10000, 1000, tempFolder.getRoot())) .isInstanceOf(IOException.class); assertThat(tempFolder.getRoot().list()).isNullOrEmpty(); }
@Override public void close() throws IOException { if (!closed) { this.in.close(); if (this.tmpFile != null) { Files.delete(this.tmpFile.toPath()); } closed = true; } }
DeferredFileBufferingInputStream extends ProxyInputStream { @Override public void close() throws IOException { if (!closed) { this.in.close(); if (this.tmpFile != null) { Files.delete(this.tmpFile.toPath()); } closed = true; } } }
DeferredFileBufferingInputStream extends ProxyInputStream { @Override public void close() throws IOException { if (!closed) { this.in.close(); if (this.tmpFile != null) { Files.delete(this.tmpFile.toPath()); } closed = true; } } DeferredFileBufferingInputStream(InputStream sourceInputStream, long sourceSize, int maxInMemoryBufferSize,
        File tmpDirectory); }
DeferredFileBufferingInputStream extends ProxyInputStream { @Override public void close() throws IOException { if (!closed) { this.in.close(); if (this.tmpFile != null) { Files.delete(this.tmpFile.toPath()); } closed = true; } } DeferredFileBufferingInputStream(InputStream sourceInputStream, long sourceSize, int maxInMemoryBufferSize,
        File tmpDirectory); @Override void close(); }
DeferredFileBufferingInputStream extends ProxyInputStream { @Override public void close() throws IOException { if (!closed) { this.in.close(); if (this.tmpFile != null) { Files.delete(this.tmpFile.toPath()); } closed = true; } } DeferredFileBufferingInputStream(InputStream sourceInputStream, long sourceSize, int maxInMemoryBufferSize,
        File tmpDirectory); @Override void close();  }