X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fosgi%2FNetconfSSHActivator.java;h=8b3c5d70adfae08090eaa0c8a3f2a210ed743726;hp=1bce3143d5a8fc29831bc5b90a62fdad8d9376ad;hb=d8e877f7de00cf86b72ff6cd77d932cf8983646b;hpb=a54b4f7301e0ad3f3ebf2f4cf6ce390348b5bc2a;ds=sidebyside diff --git a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java index 1bce3143d5..8b3c5d70ad 100644 --- a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java +++ b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.netconf.osgi; import com.google.common.base.Optional; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.net.InetSocketAddress; import org.opendaylight.controller.netconf.ssh.NetconfSSHServer; import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider; @@ -92,24 +91,12 @@ public class NetconfSSHActivator implements BundleActivator{ if (path.equals("")){ throw new Exception("Missing netconf.ssh.pk.path key in configuration file."); } - FileInputStream fis = null; - try { - fis = new FileInputStream(path); - } catch (FileNotFoundException e){ - throw new Exception("Missing file described by netconf.ssh.pk.path key in configuration file."); - } catch (SecurityException e){ - throw new Exception("Read access denied to file described by netconf.ssh.pk.path key in configuration file."); - } - AuthProvider authProvider = null; - try { - authProvider = new AuthProvider(iUserManager,fis); - } catch (Exception e){ - if (fis!=null){ - fis.close(); - } - throw (e); + + try (FileInputStream fis = new FileInputStream(path)){ + AuthProvider authProvider = new AuthProvider(iUserManager,fis); + this.server = NetconfSSHServer.start(sshSocketAddressOptional.get().getPort(),tcpSocketAddress,authProvider); } - this.server = NetconfSSHServer.start(sshSocketAddressOptional.get().getPort(),tcpSocketAddress,authProvider); + Thread serverThread = new Thread(server,"netconf SSH server thread"); serverThread.setDaemon(true); serverThread.start();