negotiationFuture);
}
- private synchronized void handleSshSetupFailure(final ChannelHandlerContext ctx, final Throwable error) {
- LOG.warn("Unable to setup SSH connection on channel: {}", ctx.channel(), error);
-
- // If the promise is not yet done, we have failed with initial connect and set connectPromise to failure
- if (!connectPromise.isDone()) {
- connectPromise.setFailure(error);
- }
-
- disconnect(ctx, ctx.newPromise());
- }
-
@Override
public synchronized void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
sshWriteAsyncHandler.write(ctx, msg, promise);
private void onConnectComplete(final ConnectFuture future, final ChannelHandlerContext ctx) {
final var cause = future.getException();
if (cause != null) {
- handleSshSetupFailure(ctx, cause);
+ onOpenFailure(ctx, cause);
return;
}
try {
authFuture = authenticationHandler.authenticate(clientSession);
} catch (final IOException e) {
- handleSshSetupFailure(ctx, e);
+ onOpenFailure(ctx, e);
return;
}
final ChannelHandlerContext ctx) {
final var cause = future.getException();
if (cause != null) {
- handleSshSetupFailure(ctx, new AuthenticationFailedException("Authentication failed", cause));
+ onOpenFailure(ctx, new AuthenticationFailedException("Authentication failed", cause));
return;
}
channel.setStreaming(ClientChannel.Streaming.Async);
openFuture = channel.open();
} catch (final IOException e) {
- handleSshSetupFailure(ctx, e);
+ onOpenFailure(ctx, e);
return;
}
private void onOpenComplete(final OpenFuture future, final ChannelHandlerContext ctx) {
final var cause = future.getException();
if (cause != null) {
- handleSshSetupFailure(ctx, cause);
+ onOpenFailure(ctx, cause);
return;
}
channel.onClose(() -> disconnect(ctx, ctx.newPromise()));
}
+ private synchronized void onOpenFailure(final ChannelHandlerContext ctx, final Throwable cause) {
+ LOG.warn("Unable to setup SSH connection on channel: {}", ctx.channel(), cause);
+
+ // If the promise is not yet done, we have failed with initial connect and set connectPromise to failure
+ if (!connectPromise.isDone()) {
+ connectPromise.setFailure(cause);
+ }
+
+ disconnect(ctx, ctx.newPromise());
+ }
+
@Override
public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) {
disconnect(ctx, promise);