From ee4dd50b3f5caa0536d2635df80ad4067d2cf4c9 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 7 Mar 2018 14:39:39 +0900 Subject: [PATCH] JschConfigSessionFactory: Open FileInputStream in try-with-resource Change-Id: I0f8f4629c93ed747f2f604538fccc52da3974b2e Signed-off-by: David Pursehouse --- .../eclipse/jgit/transport/JschConfigSessionFactory.java | 9 ++------- 1 file changed, 2 insertions(+), 7 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 c38182741..2a222fbc7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java @@ -362,13 +362,8 @@ private static void knownHosts(final JSch sch, FS fs) throws JSchException { if (home == null) return; final File known_hosts = new File(new File(home, ".ssh"), "known_hosts"); //$NON-NLS-1$ //$NON-NLS-2$ - try { - final FileInputStream in = new FileInputStream(known_hosts); - try { - sch.setKnownHosts(in); - } finally { - in.close(); - } + try (FileInputStream in = new FileInputStream(known_hosts)) { + sch.setKnownHosts(in); } catch (FileNotFoundException none) { // Oh well. They don't have a known hosts in home. } catch (IOException err) {