Revert "Upgrade mina-sshd to 2.4.0"
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / ssh / client / NetconfSshClient.java
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);