From 44025d4c54dd8c31b8aaf9140035086d28ad309d Mon Sep 17 00:00:00 2001 From: Doug Kelly Date: Thu, 24 Apr 2014 14:37:27 -0500 Subject: [PATCH] Automatically reload known_hosts file JGit caches the contents of the known_hosts file within JSch when first started, and never attempts to re-read it. If the contents change (such as when using Gerrit replication), the new host will never be found. On failures, try reloading the knonwn_hosts and retry the connection, in addition to reloading the credentials. Change-Id: I980c4f4003f2a48c71b9b47c51e640d1e7742f58 Signed-off-by: Doug Kelly --- .../org/eclipse/jgit/transport/JschConfigSessionFactory.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java index 36d429a02..65e9d4dc5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java @@ -117,6 +117,9 @@ public synchronized RemoteSession getSession(URIish uri, } catch (JSchException e) { session.disconnect(); session = null; + // Make sure our known_hosts is not outdated + knownHosts(getJSch(hc, fs), fs); + // if authentication failed maybe credentials changed at the // remote end therefore reset credentials and retry if (credentialsProvider != null && e.getCause() == null