One major issue in sdnc/northbound module
*This is done for a guaranteed closing of resource
and avoiding the finally block
Issue-Id: CCSDK-87
Change-Id: I3ab9119f0b10f47d16864aa3619cc54e069bb9de
Signed-off-by: surya-huawei <a.u.surya@huawei.com>
File propFile = new File(ODLHOME.getAbsolutePath() + "/configuration/vnfapi.properties");
String propFileName = propFile.getAbsolutePath();
properties = new Properties();
File propFile = new File(ODLHOME.getAbsolutePath() + "/configuration/vnfapi.properties");
String propFileName = propFile.getAbsolutePath();
properties = new Properties();
- InputStream input = null;
if (propFile.isFile() && propFile.canRead()) {
if (propFile.isFile() && propFile.canRead()) {
- try {
- input = new FileInputStream(propFile);
+ try (InputStream input = new FileInputStream(propFile)) {
properties.load(input);
LOG.info("Loaded properties from " + propFileName );
setYangMappingProperties(properties);
properties.load(input);
LOG.info("Loaded properties from " + propFileName );
setYangMappingProperties(properties);
+ } catch (IOException e) {
+ LOG.error("Failed to close properties file " + propFileName +"\n",e);
} catch (Exception e) {
LOG.error("Failed to load properties " + propFileName +"\n",e);
} catch (Exception e) {
LOG.error("Failed to load properties " + propFileName +"\n",e);
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- LOG.error("Failed to close properties file " + propFileName +"\n",e);
- }
- }