JschConfigSessionFactory: Open FileInputStream in try-with-resource
Change-Id: I0f8f4629c93ed747f2f604538fccc52da3974b2e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
3195d2fb9b
commit
ee4dd50b3f
|
@ -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 {
|
||||
try (FileInputStream in = new FileInputStream(known_hosts)) {
|
||||
sch.setKnownHosts(in);
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
} catch (FileNotFoundException none) {
|
||||
// Oh well. They don't have a known hosts in home.
|
||||
} catch (IOException err) {
|
||||
|
|
Loading…
Reference in New Issue