@Override public void operationComplete(ChannelFuture f) throws Exception { if (!cf.isDone()) { cf.setFailure(new ClosedChannelException()); } } });
private void processConnectTimeout(Set<SelectionKey> keys, long currentTimeNanos) { ConnectException cause = null; for (SelectionKey k: keys) { if (!k.isValid()) { continue; } SctpClientChannel ch = (SctpClientChannel) k.attachment(); if (ch.connectDeadlineNanos > 0 && currentTimeNanos >= ch.connectDeadlineNanos) { if (cause == null) { cause = new ConnectException("connection timed out"); } ch.connectFuture.setFailure(cause); fireExceptionCaught(ch, cause); ch.worker.close(ch, succeededFuture(ch)); } } }
public ChannelFuture handshake() { ... if (exception == null) { // Began handshake successfully. try { final ChannelFuture hsFuture = handshakeFuture; wrapNonAppData(ctx, channel).addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { Throwable cause = future.getCause(); hsFuture.setFailure(cause); fireExceptionCaught(ctx, cause); if (closeOnSSLException) { Channels.close(ctx, future(channel)); } } else { hsFuture.setSuccess(); } } }); } catch (SSLException e) {
private void connect(SelectionKey k) { SctpClientChannel ch = (SctpClientChannel) k.attachment(); try { if (ch.channel.finishConnect()) { k.cancel(); ch.worker.register(ch, ch.connectFuture); } } catch (Throwable t) { ch.connectFuture.setFailure(t); fireExceptionCaught(ch, t); k.cancel(); // Some JDK implementations run into an infinite loop without this. ch.worker.close(ch, succeededFuture(ch)); } }
private void unbindAddress( SctpServerChannelImpl channel, ChannelFuture future, InetAddress localAddress) { try { channel.serverChannel.unbindAddress(localAddress); future.setSuccess(); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
private void unbindAddress( SctpClientChannel channel, ChannelFuture future, InetAddress localAddress) { try { channel.channel.unbindAddress(localAddress); future.setSuccess(); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
private void bindAddress( SctpClientChannel channel, ChannelFuture future, InetAddress localAddress) { try { channel.channel.bindAddress(localAddress); future.setSuccess(); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
private void bindAddress( SctpServerChannelImpl channel, ChannelFuture future, InetAddress localAddress) { try { channel.serverChannel.bindAddress(localAddress); future.setSuccess(); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
future.setFailure(cce); fireExceptionCaught(channel, cce); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t);
channel.currentWriteEvent = null; evt = null; future.setFailure(cause); fireExceptionCaught = true; break; evt.getFuture().setFailure(cause); fireExceptionCaught = true;
private void connect( final SctpClientChannel channel, final ChannelFuture cf, SocketAddress remoteAddress) { try { if (channel.channel.connect(remoteAddress)) { channel.worker.register(channel, cf); } else { channel.getCloseFuture().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture f) throws Exception { if (!cf.isDone()) { cf.setFailure(new ClosedChannelException()); } } }); cf.addListener(ChannelFutureListener.CLOSE_ON_FAILURE); channel.connectFuture = cf; boss.register(channel); } } catch (Throwable t) { cf.setFailure(t); fireExceptionCaught(channel, t); channel.worker.close(channel, succeededFuture(channel)); } }
private void bind( SctpClientChannel channel, ChannelFuture future, SocketAddress localAddress) { try { channel.channel.bind(localAddress); channel.boundManually = true; channel.setBound(); future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
future.setFailure(t); fireExceptionCaught(channel, t);
if (localAddress == null || remoteAddress == null) { if (future != null) { future.setFailure(new ClosedChannelException()); future.setFailure(e);
void close(SctpChannelImpl channel, ChannelFuture future) { boolean connected = channel.isConnected(); boolean bound = channel.isBound(); try { channel.channel.close(); cancelledKeys++; if (channel.setClosed()) { future.setSuccess(); if (connected) { fireChannelDisconnected(channel); } if (bound) { fireChannelUnbound(channel); } cleanUpWriteBuffer(channel); fireChannelClosed(channel); } else { future.setSuccess(); } } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } }
private void bind( SctpServerChannelImpl channel, ChannelFuture future, SocketAddress localAddress) { boolean bound = false; boolean bossStarted = false; try { channel.serverChannel.bind(localAddress, channel.getConfig().getBacklog()); bound = true; channel.setBound(); future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); Executor bossExecutor = ((SctpServerSocketChannelFactory) channel.getFactory()).bossExecutor; DeadLockProofWorker.start(bossExecutor, new Boss(channel)); bossStarted = true; } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } finally { if (!bossStarted && bound) { close(channel, future); } } }
buf = null; evt = null; future.setFailure(t); fireExceptionCaught(channel, t); if (t instanceof IOException) {