if (entry == null) {
return DefaultConnectFuture.newFailedFuture(new IOException(
"Endpoint unavailable: " + remoteAddress));
}
DefaultConnectFuture future = new DefaultConnectFuture();
// Assign the local address dynamically,
VmPipeAddress actualLocalAddress;
try {
actualLocalAddress = nextLocalAddress();
} catch (IOException e) {
return DefaultConnectFuture.newFailedFuture(e);
}
VmPipeSessionImpl localSession = new VmPipeSessionImpl(this,
getListeners(), actualLocalAddress, getHandler(), entry);
finishSessionInitialization(localSession, future, ioSessionInitializer);
// and reclaim the local address when the connection is closed.
localSession.getCloseFuture().addListener(LOCAL_ADDRESS_RECLAIMER);
// initialize connector session
try {
IoFilterChain filterChain = localSession.getFilterChain();
this.getFilterChainBuilder().buildFilterChain(filterChain);
// The following sentences don't throw any exceptions.
getListeners().fireSessionCreated(localSession);
IdleStatusChecker.getInstance().addSession(localSession);
} catch (Throwable t) {
future.setException(t);
return future;
}
// initialize acceptor session
VmPipeSessionImpl remoteSession = localSession.getRemoteSession();