Improve default client parameters 41/102741/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Oct 2022 15:15:14 +0000 (17:15 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Oct 2022 15:15:14 +0000 (17:15 +0200)
Properties can be directly set, use that instead of mucking with strings
and maps.

Change-Id: I90dbef2431dff8206532445998177b7cb903928c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java

index 98f049369b43f06c71479a10c43ca00a5a2b667d..b659187b8732dc37dd582318c6854005f491f850 100644 (file)
@@ -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);