From 730b9c8d0751b0611dea5338726e507a71ed7184 Mon Sep 17 00:00:00 2001
From: Mat Booth <mat.booth@redhat.com>
Date: Fri, 7 Dec 2018 10:33:23 +0000
Subject: [PATCH 3/3] Port to apache-sshd 2.1.0

IoConnector.connect() grew an extra parameter to support specifying
the local bind port/address. Passing null continues to use an
automatically selected ephemeral port/address.

The shutdownOnExit parameter was removed everywhere the use of
'java.util.concurrent.ExecutorService' was substituted for the use
of 'org.apache.sshd.common.util.threads.ExecutorService'
---
 .../META-INF/MANIFEST.MF                      | 42 +++++-----
 .../jgit/junit/ssh/SshTestGitServer.java      | 15 ++--
 .../META-INF/MANIFEST.MF                      | 80 +++++++++----------
 .../transport/sshd/JGitSshClient.java         |  2 +-
 pom.xml                                       |  2 +-
 5 files changed, 71 insertions(+), 70 deletions(-)

diff --git a/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF b/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF
index aa11f7a..a52526d 100644
--- a/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF
@@ -8,27 +8,27 @@ Bundle-Localization: plugin
 Bundle-Vendor: %provider_name
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: org.apache.sshd.common;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.config.keys;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.file.virtualfs;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.helpers;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.io;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.kex;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.keyprovider;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.session;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.buffer;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.logging;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.security;version="[2.0.0,2.1.0)",
- org.apache.sshd.server;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.auth;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.auth.gss;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.auth.keyboard;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.auth.password;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.command;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.session;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.shell;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.subsystem;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.subsystem.sftp;version="[2.0.0,2.1.0)",
+Import-Package: org.apache.sshd.common;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.config.keys;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.file.virtualfs;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.helpers;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.io;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.kex;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.keyprovider;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.session;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.buffer;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.logging;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.security;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.auth;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.auth.gss;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.auth.keyboard;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.auth.password;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.command;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.session;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.shell;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.subsystem;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.subsystem.sftp;version="[2.1.0,2.2.0)",
  org.eclipse.jgit.annotations;version="[5.2.0,5.3.0)",
  org.eclipse.jgit.lib;version="[5.2.0,5.3.0)",
  org.eclipse.jgit.transport;version="[5.2.0,5.3.0)",
diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
index f5af2e5..d680f48 100644
--- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
+++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
@@ -55,7 +55,6 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
-import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import org.apache.sshd.common.NamedFactory;
@@ -67,6 +66,8 @@
 import org.apache.sshd.common.session.Session;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.security.SecurityUtils;
+import org.apache.sshd.common.util.threads.CloseableExecutorService;
+import org.apache.sshd.common.util.threads.ThreadUtils;
 import org.apache.sshd.server.ServerAuthenticationManager;
 import org.apache.sshd.server.SshServer;
 import org.apache.sshd.server.auth.UserAuth;
@@ -110,8 +111,8 @@
 	@NonNull
 	protected PublicKey testKey;
 
-	private final ExecutorService executorService = Executors
-			.newFixedThreadPool(2);
+	private final CloseableExecutorService executorService = ThreadUtils
+			.newFixedThreadPool("", 2);
 
 	/**
 	 * Creates a ssh git <em>test</em> server. It serves one single repository,
@@ -341,8 +342,8 @@ public void setTestUserPublicKey(Path key)
 	private class GitUploadPackCommand extends AbstractCommandSupport {
 
 		protected GitUploadPackCommand(String command,
-				ExecutorService executorService) {
-			super(command, executorService, false);
+				CloseableExecutorService executorService) {
+			super(command, executorService);
 		}
 
 		@Override
@@ -370,8 +371,8 @@ public void run() {
 	private class GitReceivePackCommand extends AbstractCommandSupport {
 
 		protected GitReceivePackCommand(String command,
-				ExecutorService executorService) {
-			super(command, executorService, false);
+				CloseableExecutorService executorService) {
+			super(command, executorService);
 		}
 
 		@Override
diff --git a/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF b/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF
index e93fc1f..45a8d81 100644
--- a/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF
@@ -32,46 +32,46 @@ Export-Package: org.eclipse.jgit.internal.transport.sshd;version="5.2.0";x-inter
    org.apache.sshd.client.session,
    org.apache.sshd.client.keyverifier"
 Import-Package: net.i2p.crypto.eddsa;version="[0.3.0,0.4.0)",
- org.apache.sshd.agent;version="[2.0.0,2.1.0)",
- org.apache.sshd.client;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.auth;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.auth.keyboard;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.auth.password;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.auth.pubkey;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.channel;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.config.hosts;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.config.keys;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.future;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.keyverifier;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.session;version="[2.0.0,2.1.0)",
- org.apache.sshd.client.subsystem.sftp;version="[2.0.0,2.1.0)",
- org.apache.sshd.common;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.auth;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.channel;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.compression;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.config.keys;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.config.keys.loader;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.digest;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.forward;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.future;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.helpers;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.io;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.kex;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.keyprovider;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.mac;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.random;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.session;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.session.helpers;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.signature;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.subsystem.sftp;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.buffer;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.closeable;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.io;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.logging;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.net;version="[2.0.0,2.1.0)",
- org.apache.sshd.common.util.security;version="[2.0.0,2.1.0)",
- org.apache.sshd.server.auth;version="[2.0.0,2.1.0)",
+ org.apache.sshd.agent;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.auth;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.auth.keyboard;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.auth.password;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.auth.pubkey;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.channel;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.config.hosts;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.config.keys;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.future;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.keyverifier;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.session;version="[2.1.0,2.2.0)",
+ org.apache.sshd.client.subsystem.sftp;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.auth;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.channel;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.compression;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.config.keys;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.config.keys.loader;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.digest;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.forward;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.future;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.helpers;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.io;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.kex;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.keyprovider;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.mac;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.random;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.session;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.session.helpers;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.signature;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.subsystem.sftp;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.buffer;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.closeable;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.io;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.logging;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.net;version="[2.1.0,2.2.0)",
+ org.apache.sshd.common.util.security;version="[2.1.0,2.2.0)",
+ org.apache.sshd.server.auth;version="[2.1.0,2.2.0)",
  org.eclipse.jgit.annotations;version="[5.2.0,5.3.0)",
  org.eclipse.jgit.errors;version="[5.2.0,5.3.0)",
  org.eclipse.jgit.fnmatch;version="[5.2.0,5.3.0)",
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
index 212b67f..5d78728 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
@@ -149,7 +149,7 @@ public ConnectFuture connect(HostConfigEntry hostConfig)
 			address = configureProxy(proxy, address);
 			proxy.clearPassword();
 		}
-		connector.connect(address).addListener(listener);
+		connector.connect(address,null).addListener(listener);
 		return connectFuture;
 	}
 
diff --git a/pom.xml b/pom.xml
index 2528cb4..ff67f9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -198,7 +198,7 @@
     <bundle-manifest>${project.build.directory}/META-INF/MANIFEST.MF</bundle-manifest>
 
     <jgit-last-release-version>4.11.0.201803080745-r</jgit-last-release-version>
-    <apache-sshd-version>2.0.0</apache-sshd-version>
+    <apache-sshd-version>2.1.0</apache-sshd-version>
     <jsch-version>0.1.54</jsch-version>
     <jzlib-version>1.1.1</jzlib-version>
     <javaewah-version>1.1.6</javaewah-version>
-- 
2.19.1

