tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject incubator-tamaya git commit: TAMAYA-57 PropertiesFileLoader uses now try-with-resources to read a resource.
Date Tue, 10 Feb 2015 06:47:43 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master ab4835d31 -> a832de494


TAMAYA-57 PropertiesFileLoader uses now try-with-resources to read a resource.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a832de49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a832de49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a832de49

Branch: refs/heads/master
Commit: a832de49445289f60e5dcaefe9d406fb2a39c61c
Parents: ab4835d
Author: Oliver B. Fischer <plexus@apache.org>
Authored: Tue Feb 10 07:47:09 2015 +0100
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Tue Feb 10 07:47:09 2015 +0100

----------------------------------------------------------------------
 .../tamaya/core/internal/PropertiesFileLoader.java  | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a832de49/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java
----------------------------------------------------------------------
diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java
b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java
index becb4bb..3e2f550 100644
--- a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java
+++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tamaya.core.internal;
 
+import org.apache.tamaya.ConfigException;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -70,23 +72,13 @@ public final class PropertiesFileLoader {
 
         Properties properties = new Properties();
 
-        InputStream stream = null;
-        try {
-            stream = propertiesFile.openStream();
+        try (InputStream stream = propertiesFile.openStream()) {
 
             if (stream != null) {
                 properties.load(stream);
             }
         } catch (IOException e) {
-            throw new IllegalStateException("Error loading Properties " + propertiesFile,
e);
-        } finally {
-            if (stream != null) {
-                try {
-                    stream.close();
-                } catch (IOException e) {
-                    // bad luck -> stream is already closed
-                }
-            }
+            throw new ConfigException("Error loading properties " + propertiesFile, e);
         }
 
         return properties;


Mime
View raw message