@Override public void write(int b) throws IOException { throw new ClosedChannelException(); } };
@Override public void write(int b) throws IOException { throw new ClosedChannelException(); } };
@Override public void write(int b) throws IOException { throw new ClosedChannelException(); } };
@Override void handleClose() { Handler<Throwable> handler; synchronized (conn) { handler = streamEnded ? null : exceptionHandler; } if (handler != null) { handler.handle(new ClosedChannelException()); } response.handleClose(); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { // Only the client is expected to close the channel. Otherwise it // indicates a failure. Note that this will be invoked in both cases // though. If the callback closed the channel, the callback must be // ignored. try { callback.onFailure(new ClosedChannelException()); } catch (Throwable t) { LOG.error("Failed to notify callback about failure", t); } } }
/** * Returns {@code true} if the {@link Channel} is open and records optionally * an {@link Exception} if it isn't. */ private boolean checkOpen(boolean recordException) { if (!isOpen()) { if (recordException) { recordException(new ClosedChannelException()); } return false; } return true; }
private void close0() { if (!closed) { closed = true; for (;;) { AcquireTask task = pendingAcquireQueue.poll(); if (task == null) { break; } ScheduledFuture<?> f = task.timeoutFuture; if (f != null) { f.cancel(false); } task.promise.setFailure(new ClosedChannelException()); } acquiredChannelCount.set(0); pendingAcquireCount = 0; // Ensure we dispatch this on another Thread as close0 will be called from the EventExecutor and we need // to ensure we will not block in a EventExecutor. GlobalEventExecutor.INSTANCE.execute(new Runnable() { @Override public void run() { FixedChannelPool.super.close(); } }); } } }
protected void lastDataRead() { if(!lastFrameSent) { markReadsBroken(new ClosedChannelException()); markWritesBroken(new ClosedChannelException()); } lastFrameReceived = true; lastFrameSent = true; IoUtils.safeClose(this); }
/** * Returns {@code true} if the {@link Channel} is open and records optionally * an {@link Exception} if it isn't. */ private boolean checkOpen(boolean recordException) { if (!isOpen()) { if (recordException) { recordException(new ClosedChannelException()); } return false; } return true; }
@Override public long transferFrom(FileChannel src, long position, long count) throws IOException { if(anyAreSet(state, FLAG_WRITE_SHUTDOWN)) { throw new ClosedChannelException(); } return src.transferTo(position, count, new ConduitWritableByteChannel(this)); }
@Override public long transferFrom(final FileChannel src, final long position, final long count) throws IOException { if (anyAreSet(state, FLAG_WRITES_SHUTDOWN)) { throw new ClosedChannelException(); } return src.transferTo(position, count, new ConduitWritableByteChannel(this)); }
@Override public int write(ByteBuffer src) throws IOException { if(anyAreSet(state, FLAG_WRITE_SHUTDOWN)) { throw new ClosedChannelException(); } return (int) doWrap(new ByteBuffer[]{src}, 0, 1); }
@Override public long write(ByteBuffer[] srcs, int offs, int len) throws IOException { if(anyAreSet(state, FLAG_WRITE_SHUTDOWN)) { throw new ClosedChannelException(); } return doWrap(srcs, offs, len); }
private Throwable wrapStreamClosedError(Throwable cause) { // If the error was caused by STREAM_CLOSED we should use a ClosedChannelException to better // mimic other transports and make it easier to reason about what exceptions to expect. if (cause instanceof Http2Exception && ((Http2Exception) cause).error() == Http2Error.STREAM_CLOSED) { return new ClosedChannelException().initCause(cause); } return cause; }
void beginHandshake() throws IOException { final int state = this.state; if (anyAreSet(state, READ_FLAG_EOF | WRITE_FLAG_SHUTDOWN)) { throw new ClosedChannelException(); } if (allAreClear(state, FLAG_TLS)) { this.state = state | FLAG_TLS; } engine.beginHandshake(); }
@Override public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { if (anyAreSet(state, FLAG_WRITES_SHUTDOWN)) { throw new ClosedChannelException(); } return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); }
@Override public long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException { if(anyAreSet(state, FLAG_WRITE_SHUTDOWN)) { throw new ClosedChannelException(); } return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); }
@Override public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { if (anyAreSet(state, FLAG_CLOSE_COMPLETE)) { throw new ClosedChannelException(); } return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); }
@Override public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { if (anyAreSet(state, SHUTDOWN | CLOSED)) { throw new ClosedChannelException(); } if (!performFlushIfRequired()) { return 0; } return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); }
private void checkIfClosedOrInterrupted() throws IOException { if ( !isOpen() ) { throw new ClosedChannelException(); } if ( Thread.currentThread().isInterrupted() ) { close(); throw new ClosedByInterruptException(); } }