Change "try" to try-with-resources
[sdnc/northbound.git] / vnfapi / provider / src / main / java / org / onap / sdnc / vnfapi / VnfSdnUtil.java
index 69f5922..522ee7f 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,7 @@ public class VnfSdnUtil extends MdsalHelper {
 
     private static final Logger LOG = LoggerFactory.getLogger(VnfSdnUtil.class);
 
-    public static File ODLHOME = null;
+    private static File ODLHOME = null;
 
     private static Properties properties;
 
@@ -53,23 +53,15 @@ public class VnfSdnUtil extends MdsalHelper {
         File propFile = new File(ODLHOME.getAbsolutePath() + "/configuration/vnfapi.properties");
         String propFileName = propFile.getAbsolutePath();
         properties = new Properties();
-        InputStream input = null;
         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 );
-                setProperties(properties);
+                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);
-            } finally {
-                if (input != null) {
-                    try {
-                        input.close();
-                    } catch (IOException e) {
-                        LOG.error("Failed to close properties file " + propFileName +"\n",e);
-                    }
-                }
             }
         }
     }