List of usage examples for java.io InterruptedIOException InterruptedIOException
public InterruptedIOException()
InterruptedIOException
with null
as its error detail message. From source file:org.globus.ftp.OutputStreamDataSource.java
public Buffer read() throws IOException { try {/*from w ww. j a v a2 s . co m*/ return (Buffer) this.buffers.get(); } catch (InterruptedException e) { // that should not happen throw new InterruptedIOException(); } }
From source file:org.apache.sling.testing.clients.interceptors.DelayRequestInterceptor.java
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { if (milliseconds <= 0) { return;/*w w w .j av a 2s . c om*/ } try { Thread.sleep(milliseconds); } catch (InterruptedException e) { throw new InterruptedIOException(); } }
From source file:org.globus.ftp.InputStreamDataSink.java
public void write(Buffer buffer) throws IOException { if (isClosed()) { throw new EOFException(); }//from w w w.j ava 2 s .c o m try { if (!buffers.put(buffer)) { throw new EOFException(); } } catch (InterruptedException e) { throw new InterruptedIOException(); } }
From source file:org.sonatype.nexus.proxy.storage.remote.httpclient.InterruptableInputStream.java
private void abortIfInterrupted() throws IOException { if (Thread.interrupted()) { if (request != null) { request.abort();// w ww. j a v a 2 s . com } throw new InterruptedIOException(); } }
From source file:com.haulmont.cuba.gui.upload.FileStorageProgressEntity.java
@Override public void writeTo(OutputStream outStream) throws IOException { long transferredBytes = 0L; if (outStream == null) { throw new IllegalArgumentException("Output stream may not be null"); }/*from ww w . ja va 2 s .c o m*/ try (InputStream inStream = new FileInputStream(this.file)) { byte[] tmp = new byte[4096]; int readedBytes; while ((readedBytes = inStream.read(tmp)) != -1) { if (Thread.currentThread().isInterrupted()) throw new InterruptedIOException(); outStream.write(tmp, 0, readedBytes); transferredBytes += readedBytes; try { listener.progressChanged(fileId, transferredBytes, size); } catch (InterruptedException e) { throw new InterruptedIOException(); } } outStream.flush(); } }
From source file:com.haulmont.cuba.client.sys.fileupload.InputStreamProgressEntity.java
@Override public void writeTo(OutputStream outStream) throws IOException { if (outStream == null) { throw new IllegalArgumentException("Output stream may not be null"); }/*from www. j a v a2 s. c o m*/ long transferredBytes = 0; final byte[] buffer = new byte[OUTPUT_BUFFER_SIZE]; int readBytes; while ((readBytes = this.content.read(buffer)) != -1) { // check interrupted only if listener is set if (listener != null && Thread.currentThread().isInterrupted()) { throw new InterruptedIOException(); } outStream.write(buffer, 0, readBytes); transferredBytes += readBytes; if (listener != null) { listener.onUploadProgressChanged(transferredBytes); } } }
From source file:org.eclipse.emf.mwe.internal.core.debug.communication.PackageSender.java
/** * Add a packet to be sent to the other side. * /*from w ww. j a v a 2s .co m*/ * @param packet the packet * @return the packet id after it was sent * @throws InterruptedIOException */ public int sendPackage(final AbstractPackage packet) throws InterruptedIOException { if (!connection.isConnected()) { throw new InterruptedIOException(); // log.debug("send: " + packet); } synchronized (outgoingPackages) { outgoingPackages.add(packet); outgoingPackages.notifyAll(); } return packet.getId(); }
From source file:org.apache.sshd.common.channel.ChannelOutputStream.java
public synchronized void write(byte[] buf, int s, int l) throws IOException { if (closed) { throw new SshException("Already closed"); }/*from w ww . java 2 s.c o m*/ while (l > 0) { // The maximum amount we should admit without flushing again // is enough to make up one full packet within our allowed // window size. We give ourselves a credit equal to the last // packet we sent to allow the producer to race ahead and fill // out the next packet before we block and wait for space to // become available again. // int _l = Math.min(l, Math.min(remoteWindow.getSize() + lastSize, remoteWindow.getPacketSize()) - bufferLength); if (_l <= 0) { if (bufferLength > 0) { flush(); } else { try { remoteWindow.waitForSpace(); } catch (WindowClosedException e) { closed = true; throw e; } catch (InterruptedException e) { throw (IOException) new InterruptedIOException().initCause(e); } } continue; } buffer.putRawBytes(buf, s, _l); bufferLength += _l; s += _l; l -= _l; } }
From source file:byps.http.HIncomingSplittedStreamAsync.java
private HIncomingStreamAsync getCurrentStreamPart(boolean nextPart) throws IOException { if (nextPart || currentStreamPart == null) { long t1 = System.currentTimeMillis(); long timeout = lifetimeMillis; synchronized (this) { if (nextPart) currentPartId++;/*from w w w . j a v a2 s . c om*/ if (currentPartId < maxPartId) { currentStreamPart = streamParts.get(currentPartId); while (currentStreamPart == null) { try { wait(timeout); long t2 = System.currentTimeMillis(); if (t2 - t1 > timeout) { throw new BException(BExceptionC.TIMEOUT, "Timeout while reading stream part"); } } catch (InterruptedException e) { throw new InterruptedIOException(); } currentStreamPart = streamParts.get(currentPartId); } } else { currentStreamPart = null; } } } return currentStreamPart; }
From source file:org.apache.hadoop.hbase.master.handler.DeleteTableHandler.java
protected void waitRegionInTransition(final List<HRegionInfo> regions) throws IOException, CoordinatedStateException { AssignmentManager am = this.masterServices.getAssignmentManager(); RegionStates states = am.getRegionStates(); long waitTime = server.getConfiguration().getLong("hbase.master.wait.on.region", 5 * 60 * 1000); for (HRegionInfo region : regions) { long done = System.currentTimeMillis() + waitTime; while (System.currentTimeMillis() < done) { if (states.isRegionInState(region, State.FAILED_OPEN)) { am.regionOffline(region); }//www.j a v a 2 s .c o m if (!states.isRegionInTransition(region)) break; try { Thread.sleep(waitingTimeForEvents); } catch (InterruptedException e) { LOG.warn("Interrupted while sleeping"); throw (InterruptedIOException) new InterruptedIOException().initCause(e); } LOG.debug("Waiting on region to clear regions in transition; " + am.getRegionStates().getRegionTransitionState(region)); } if (states.isRegionInTransition(region)) { throw new IOException("Waited hbase.master.wait.on.region (" + waitTime + "ms) for region to leave region " + region.getRegionNameAsString() + " in transitions"); } } }