JschConfigSessionFactory: Open FileInputStream in try-with-resource

Change-Id: I0f8f4629c93ed747f2f604538fccc52da3974b2e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2018-03-07 14:39:39 +09:00
parent 3195d2fb9b
commit ee4dd50b3f
1 changed files with 2 additions and 7 deletions

View File

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