@Test public void testChannelFactoryFailureNotifiesPromise() throws Exception { final RuntimeException exception = new RuntimeException("newChannel crash"); final Bootstrap bootstrap = new Bootstrap() .handler(dummyHandler) .group(groupA) .channelFactory(new ChannelFactory<Channel>() { @Override public Channel newChannel() { throw exception; } }); ChannelFuture connectFuture = bootstrap.connect(LocalAddress.ANY); assertThat(connectFuture.await(10000), is(true)); assertThat(connectFuture.cause(), sameInstance((Throwable) exception)); assertThat(connectFuture.channel(), is(not(nullValue()))); }
public ChannelFuture connect() { validate(); SocketAddress remoteAddress = this.remoteAddress; if (remoteAddress == null) { throw new IllegalStateException("remoteAddress not set"); } return doResolveAndConnect(remoteAddress, config.localAddress()); }
Bootstrap extends AbstractBootstrap<Bootstrap, Channel> { public ChannelFuture connect() { validate(); SocketAddress remoteAddress = this.remoteAddress; if (remoteAddress == null) { throw new IllegalStateException("remoteAddress not set"); } return doResolveAndConnect(remoteAddress, config.localAddress()); } }
Bootstrap extends AbstractBootstrap<Bootstrap, Channel> { public ChannelFuture connect() { validate(); SocketAddress remoteAddress = this.remoteAddress; if (remoteAddress == null) { throw new IllegalStateException("remoteAddress not set"); } return doResolveAndConnect(remoteAddress, config.localAddress()); } Bootstrap(); private  Bootstrap(Bootstrap bootstrap); }
Bootstrap extends AbstractBootstrap<Bootstrap, Channel> { public ChannelFuture connect() { validate(); SocketAddress remoteAddress = this.remoteAddress; if (remoteAddress == null) { throw new IllegalStateException("remoteAddress not set"); } return doResolveAndConnect(remoteAddress, config.localAddress()); } Bootstrap(); private  Bootstrap(Bootstrap bootstrap); @SuppressWarnings("unchecked") Bootstrap resolver(AddressResolverGroup<?> resolver); Bootstrap remoteAddress(SocketAddress remoteAddress); Bootstrap remoteAddress(String inetHost, int inetPort); Bootstrap remoteAddress(InetAddress inetHost, int inetPort); ChannelFuture connect(); ChannelFuture connect(String inetHost, int inetPort); ChannelFuture connect(InetAddress inetHost, int inetPort); ChannelFuture connect(SocketAddress remoteAddress); ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress); @Override Bootstrap validate(); @Override @SuppressWarnings("CloneDoesntCallSuperClone") Bootstrap clone(); Bootstrap clone(EventLoopGroup group); @Override final BootstrapConfig config(); }
Bootstrap extends AbstractBootstrap<Bootstrap, Channel> { public ChannelFuture connect() { validate(); SocketAddress remoteAddress = this.remoteAddress; if (remoteAddress == null) { throw new IllegalStateException("remoteAddress not set"); } return doResolveAndConnect(remoteAddress, config.localAddress()); } Bootstrap(); private  Bootstrap(Bootstrap bootstrap); @SuppressWarnings("unchecked") Bootstrap resolver(AddressResolverGroup<?> resolver); Bootstrap remoteAddress(SocketAddress remoteAddress); Bootstrap remoteAddress(String inetHost, int inetPort); Bootstrap remoteAddress(InetAddress inetHost, int inetPort); ChannelFuture connect(); ChannelFuture connect(String inetHost, int inetPort); ChannelFuture connect(InetAddress inetHost, int inetPort); ChannelFuture connect(SocketAddress remoteAddress); ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress); @Override Bootstrap validate(); @Override @SuppressWarnings("CloneDoesntCallSuperClone") Bootstrap clone(); Bootstrap clone(EventLoopGroup group); @Override final BootstrapConfig config();  }