From 2d8ddb23fc7f3ead7114314704319fff4dcce1a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Mon, 25 Mar 2019 22:12:01 +0100 Subject: [PATCH] Always return a configuration --- src/kaka/cakelight/Configuration.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/kaka/cakelight/Configuration.java b/src/kaka/cakelight/Configuration.java index 4a6a6a6..4f1525c 100644 --- a/src/kaka/cakelight/Configuration.java +++ b/src/kaka/cakelight/Configuration.java @@ -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) { -- 2.11.0