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 <dougk.ff7@gmail.com>
This commit is contained in:
Doug Kelly 2014-04-24 14:37:27 -05:00
parent 62bbde3393
commit 44025d4c54
1 changed files with 3 additions and 0 deletions

View File

@ -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