@Override public boolean markSupported() { return getWrappedInputStream().markSupported(); }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public int read() throws IOException { maybeInterruptInputStream(); return inputStream.read(); }
/** * Constructs an input stream based on an {@link HttpResponse} object representing an HTTP connection. * If a connection input stream is available, this constructor wraps the underlying input stream * in an {@link InterruptableInputStream} and makes that stream available. If no underlying connection * is available, an empty {@link ByteArrayInputStream} is made available. * * @param httpMethod */ public HttpMethodReleaseInputStream(HttpResponse httpMethod) { this.httpResponse = httpMethod; try { this.inputStream = new InterruptableInputStream(httpMethod.getEntity().getContent()); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Unable to obtain HttpMethod's response data stream", e); } try { EntityUtils.consume(httpMethod.getEntity()); } catch (Exception ee){ // ignore } this.inputStream = new ByteArrayInputStream(new byte[] {}); // Empty input stream; } }
private void maybeInterruptInputStream() throws IOException { if (interrupted) { if (log.isDebugEnabled()) { log.debug("Input stream interrupted, closing underlying input stream " + this.inputStream.getClass()); } try { close(); } catch (IOException ioe) { if (log.isWarnEnabled()) { log.warn("Unable to close underlying InputStream on interrupt"); } } // Throw an unrecoverable exception to indicate that this exception was deliberate, and // should not be recovered from. throw new UnrecoverableIOException("Reading from input stream deliberately interrupted"); } }
/** * Constructs an input stream based on an {@link HttpResponse} object representing an HTTP connection. * If a connection input stream is available, this constructor wraps the underlying input stream * in an {@link InterruptableInputStream} and makes that stream available. If no underlying connection * is available, an empty {@link ByteArrayInputStream} is made available. * * @param httpMethod */ public HttpMethodReleaseInputStream(HttpResponse httpMethod) { this.httpResponse = httpMethod; try { this.inputStream = new InterruptableInputStream(httpMethod.getEntity().getContent()); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Unable to obtain HttpMethod's response data stream", e); } try { EntityUtils.consume(httpMethod.getEntity()); } catch (Exception ee){ // ignore } this.inputStream = new ByteArrayInputStream(new byte[] {}); // Empty input stream; } }
private void maybeInterruptInputStream() throws IOException { if (interrupted) { if (log.isDebugEnabled()) { log.debug("Input stream interrupted, closing underlying input stream " + this.inputStream.getClass()); } try { close(); } catch (IOException ioe) { if (log.isWarnEnabled()) { log.warn("Unable to close underlying InputStream on interrupt"); } } // Throw an unrecoverable exception to indicate that this exception was deliberate, and // should not be recovered from. throw new UnrecoverableIOException("Reading from input stream deliberately interrupted"); } }
public void run() { try { File underlyingFile = object.getDataInputFile(); if (object.getDataInputStream() != null) { interruptableInputStream = new InterruptableInputStream(object.getDataInputStream()); ProgressMonitoredInputStream pmInputStream = new ProgressMonitoredInputStream( interruptableInputStream, progressMonitor); object.setDataInputStream(pmInputStream); } result = storageService.putObject(bucketName, object); if (underlyingFile instanceof TempFile) { underlyingFile.delete(); } } catch (ServiceException e) { result = e; } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public int read(byte[] b, int off, int len) throws IOException { maybeInterruptInputStream(); return inputStream.read(b, off, len); }
@Override public synchronized void reset() throws IOException { getWrappedInputStream().reset(); }
public void run() { try { if (object.getDataInputStream() != null) { interruptableInputStream = new InterruptableInputStream(object.getDataInputStream()); ProgressMonitoredInputStream pmInputStream = new ProgressMonitoredInputStream( interruptableInputStream, progressMonitor); object.setDataInputStream(pmInputStream); } ((S3Service)storageService).multipartUploadPart( multipartUpload, partNumber, object); result = object; } catch (ServiceException e) { result = e; } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public int available() throws IOException { maybeInterruptInputStream(); return inputStream.available(); }
@Override public synchronized void reset() throws IOException { getWrappedInputStream().reset(); }
public void run() { try { File underlyingFile = object.getDataInputFile(); if (object.getDataInputStream() != null) { interruptableInputStream = new InterruptableInputStream(object.getDataInputStream()); ProgressMonitoredInputStream pmInputStream = new ProgressMonitoredInputStream( interruptableInputStream, progressMonitor); object.setDataInputStream(pmInputStream); } result = storageService.putObject(bucketName, object); if (underlyingFile instanceof TempFile) { underlyingFile.delete(); } } catch (ServiceException e) { result = e; } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public int read(byte[] b, int off, int len) throws IOException { maybeInterruptInputStream(); return inputStream.read(b, off, len); }
@Override public boolean markSupported() { return getWrappedInputStream().markSupported(); }
public void run() { try { if (object.getDataInputStream() != null) { interruptableInputStream = new InterruptableInputStream(object.getDataInputStream()); ProgressMonitoredInputStream pmInputStream = new ProgressMonitoredInputStream( interruptableInputStream, progressMonitor); object.setDataInputStream(pmInputStream); } ((S3Service)storageService).multipartUploadPart( multipartUpload, partNumber, object); result = object; } catch (ServiceException e) { result = e; } }