From d9cf4638bbf31af7380656a326fc7c51007ce13c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 18 Oct 2022 17:15:14 +0200 Subject: [PATCH] Improve default client parameters Properties can be directly set, use that instead of mucking with strings and maps. Change-Id: I90dbef2431dff8206532445998177b7cb903928c Signed-off-by: Robert Varga --- .../handler/ssh/client/AsyncSshHandler.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java index 98f049369b..b659187b87 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.net.SocketAddress; +import java.time.Duration; import java.util.concurrent.TimeUnit; import org.checkerframework.checker.lock.qual.GuardedBy; import org.checkerframework.checker.lock.qual.Holding; @@ -55,12 +56,13 @@ public final class AsyncSshHandler extends ChannelOutboundHandlerAdapter { public static final NetconfSshClient DEFAULT_CLIENT; static { - final NetconfSshClient c = new NetconfClientBuilder().build(); + final var c = new NetconfClientBuilder().build(); // Disable default timeouts from mina sshd - c.getProperties().put(CoreModuleProperties.AUTH_TIMEOUT.getName(), "0"); - c.getProperties().put(CoreModuleProperties.IDLE_TIMEOUT.getName(), "0"); - c.getProperties().put(CoreModuleProperties.NIO2_READ_TIMEOUT.getName(), "0"); - c.getProperties().put(CoreModuleProperties.TCP_NODELAY.getName(), true); + final var zero = Duration.ofMillis(0); + CoreModuleProperties.AUTH_TIMEOUT.set(c, zero); + CoreModuleProperties.IDLE_TIMEOUT.set(c, zero); + CoreModuleProperties.NIO2_READ_TIMEOUT.set(c, zero); + CoreModuleProperties.TCP_NODELAY.set(c, true); // TODO make configurable, or somehow reuse netty threadpool c.setNioWorkers(SSH_DEFAULT_NIO_WORKERS); -- 2.36.6