diff options
author | Lajos Olah <lajos.olah.jr@gmail.com> | 2020-02-25 17:17:02 -0500 |
---|---|---|
committer | Lajos Olah <lajos.olah.jr@gmail.com> | 2020-02-26 03:57:59 -0500 |
commit | 61ec1455c000024c53425fe84bfb238880e46c8d (patch) | |
tree | 227050e3d8ebc5123cad1ddf49c65bc105654e85 /org.eclipse.jgit | |
parent | f63583928fc1784a98082e46fcb5d8c5445afb08 (diff) | |
download | jgit-61ec1455c000024c53425fe84bfb238880e46c8d.tar.gz jgit-61ec1455c000024c53425fe84bfb238880e46c8d.zip |
Do not fail if known hosts file does not contain valid host key
KnownHosts (implementing HostKeyRepository) in Jsch can return null
which could cause NullPointerException in Stream.of(...)
Change-Id: Iddcf5f34f8c8475a85ca7ae018bbe48d1b3fbbc0
Signed-off-by: Lajos Olah <lajos.olah.jr@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java | 8 |
1 files changed, 7 insertions, 1 deletions
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 faa917a50e..718c8f6115 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java @@ -219,7 +219,13 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory { private static void setPreferredKeyTypesOrder(Session session) { HostKeyRepository hkr = session.getHostKeyRepository(); - List<String> known = Stream.of(hkr.getHostKey(hostName(session), null)) + HostKey[] hostKeys = hkr.getHostKey(hostName(session), null); + + if (hostKeys == null) { + return; + } + + List<String> known = Stream.of(hostKeys) .map(HostKey::getType) .collect(toList()); |