Always return a configuration
authorTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 25 Mar 2019 21:12:01 +0000 (22:12 +0100)
committerTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 25 Mar 2019 21:12:01 +0000 (22:12 +0100)
src/kaka/cakelight/Configuration.java

index 4a6a6a6..4f1525c 100644 (file)
@@ -21,24 +21,13 @@ public class Configuration {
     }
 
     public static Configuration from(String propertiesFile) {
-        InputStream input = null;
-        try {
-            input = new FileInputStream(propertiesFile);
-            Properties prop = new Properties();
+        Properties prop = new Properties();
+        try (InputStream input = new FileInputStream(propertiesFile)) {
             prop.load(input);
-            return new Configuration(prop);
         } catch (IOException ex) {
             ex.printStackTrace();
-        } finally {
-            if (input != null) {
-                try {
-                    input.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
         }
-        return null;
+        return new Configuration(prop);
     }
 
     private String get(Properties prop, String name) {