NetClient and HttpClient should return a failed future instead of throwing an exception when the transport cannot create a domain socket.

This commit is contained in:
Julien Viet
2019-11-27 14:51:02 +01:00
parent 765eb6e7fc
commit 33b1cff459
4 changed files with 12 additions and 3 deletions

View File

@@ -114,7 +114,6 @@ class HttpChannelConnector implements ConnectionProvider<HttpClientConnection> {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(context.nettyEventLoop());
bootstrap.channelFactory(client.getVertx().transport().channelFactory(domainSocket));
applyConnectionOptions(domainSocket, bootstrap);

View File

@@ -35,7 +35,12 @@ public class AsyncResolveConnectHelper {
SocketAddress socketAddress,
ServerBootstrap bootstrap) {
Promise<Channel> promise = vertx.getAcceptorEventLoopGroup().next().newPromise();
bootstrap.channelFactory(vertx.transport().serverChannelFactory(socketAddress.path() != null));
try {
bootstrap.channelFactory(vertx.transport().serverChannelFactory(socketAddress.path() != null));
} catch (Exception e) {
promise.setFailure(e);
return promise;
}
if (socketAddress.path() != null) {
java.net.SocketAddress converted = vertx.transport().convert(socketAddress, true);
ChannelFuture future = bootstrap.bind(converted);

View File

@@ -77,6 +77,12 @@ public final class ChannelProvider {
}
private void connect(SocketAddress remoteAddress, SocketAddress peerAddress, String serverName, boolean ssl, Promise<Channel> p) {
try {
bootstrap.channelFactory(context.owner().transport().channelFactory(remoteAddress.path() != null));
} catch (Exception e) {
p.setFailure(e);
return;
}
if (proxyOptions != null) {
handleProxyConnect(remoteAddress, peerAddress, serverName, ssl, p);
} else {

View File

@@ -197,7 +197,6 @@ public class NetClientImpl implements MetricsProvider, NetClient {
sslHelper.validate(vertx);
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(context.nettyEventLoop());
bootstrap.channelFactory(vertx.transport().channelFactory(remoteAddress.path() != null));
applyConnectionOptions(remoteAddress.path() != null, bootstrap);