Revert "Upgrade mina-sshd to 2.4.0" 82/91882/2
authorJamo Luhrsen <jluhrsen@gmail.com>
Tue, 4 Aug 2020 22:54:11 +0000 (15:54 -0700)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 26 Aug 2020 16:10:40 +0000 (18:10 +0200)
This reverts commit 560e49a0c5d879e763eb82f737db92bc78a276d3
as well as c2e07b76734c34a2fe88262530b4ac4a387b8ee7, as these
are suspected to cause a regression.

JIRA: NETCONF-716
Change-Id: Ie73f3a7b0b4f41e690b368035f212938916b40dd
Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
(cherry picked from commit f25f45ff27c8a7c7df780df609ec33f6662ea61e)

netconf/mdsal-netconf-ssh/src/main/java/org/opendaylight/netconf/ssh/RemoteNetconfCommand.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/NetconfSshClient.java
netconf/shaded-sshd-jar/pom.xml

index d9ef852404eeaa11df5248841eb95ecceb558643..ed557f0b627d254ca29622e4642f717c5c3bb64a 100644 (file)
@@ -21,6 +21,7 @@ import java.io.OutputStream;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.shaded.sshd.common.NamedFactory;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoInputStream;
 import org.opendaylight.netconf.shaded.sshd.common.io.IoOutputStream;
 import org.opendaylight.netconf.shaded.sshd.server.Environment;
@@ -29,7 +30,6 @@ import org.opendaylight.netconf.shaded.sshd.server.channel.ChannelSession;
 import org.opendaylight.netconf.shaded.sshd.server.command.AsyncCommand;
 import org.opendaylight.netconf.shaded.sshd.server.command.Command;
 import org.opendaylight.netconf.shaded.sshd.server.session.ServerSession;
-import org.opendaylight.netconf.shaded.sshd.server.subsystem.SubsystemFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -163,7 +163,7 @@ public class RemoteNetconfCommand implements AsyncCommand {
         return netconfHelloMessageAdditionalHeader.getAddress();
     }
 
-    public static class NetconfCommandFactory implements SubsystemFactory {
+    public static class NetconfCommandFactory implements NamedFactory<Command> {
 
         public static final String NETCONF = "netconf";
 
@@ -182,7 +182,7 @@ public class RemoteNetconfCommand implements AsyncCommand {
         }
 
         @Override
-        public Command createSubsystem(final ChannelSession channel) {
+        public RemoteNetconfCommand create() {
             return new RemoteNetconfCommand(clientBootstrap, localAddress);
         }
     }
index d5d0d97aa955636191257b0ef4e8e792fbb1a9ae..7b5308a36f3d544cc6f15941237f81a765c7d921 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.netconf.nettyutil.handler.ssh.client;
 import com.google.common.annotations.Beta;
 import org.opendaylight.netconf.shaded.sshd.client.SshClient;
 import org.opendaylight.netconf.shaded.sshd.common.Factory;
+import org.opendaylight.netconf.shaded.sshd.common.forward.PortForwardingEventListener;
+import org.opendaylight.netconf.shaded.sshd.common.util.net.SshdSocketAddress;
 
 /**
  * An extension to {@link SshClient} which uses {@link NetconfSessionFactory} to create sessions (leading towards
@@ -19,6 +21,22 @@ import org.opendaylight.netconf.shaded.sshd.common.Factory;
 public class NetconfSshClient extends SshClient {
     public static final Factory<SshClient> DEFAULT_NETCONF_SSH_CLIENT_FACTORY = NetconfSshClient::new;
 
+    /*
+     * This is a workaround for sshd-core's instantiation of Proxies. AbstractFactoryManager (which is our superclass)
+     * is calling Proxy.newProxyInstance() with getClass().getClassLoader(), i.e. our class loader.
+     *
+     * Since we are not using PortForwardingEventListener, our classloader does not see it (because we do not import
+     * that package), which leads to an instantiation failure.
+     *
+     * Having these dumb fields alleviates the problem, as it forces the packages to be imported by our bundle.
+     *
+     * FIXME: Remove this once we have an SSHD version with  https://issues.apache.org/jira/browse/SSHD-975 fixed
+     */
+    static final class Sshd975Workarounds {
+        static final PortForwardingEventListener PFEL = null;
+        static final SshdSocketAddress SSA = null;
+    }
+
     @Override
     protected NetconfSessionFactory createSessionFactory() {
         return new NetconfSessionFactory(this);
index 4cdcfb3a55bc8af82863afe79f4e95ea824e69c8..e32e60fdf802c417fb0f6e4e1952748f30fee989 100644 (file)
         <dependency>
             <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-osgi</artifactId>
-            <version>2.5.1</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-netty</artifactId>
-            <version>2.5.1</version>
         </dependency>
         <dependency>
             <groupId>net.i2p.crypto</groupId>