tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [1/9] incubator-tamaya git commit: TAMAYA-53 Resources are now always closed in the URLResolver.
Date Tue, 10 Feb 2015 06:35:15 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 897703d8c -> 61753ed7e


TAMAYA-53 Resources are now always closed in the URLResolver.


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

Branch: refs/heads/master
Commit: cc1eda422db01116d5a8d3b8d999c349786eae5a
Parents: 897703d
Author: Oliver B. Fischer <plexus@apache.org>
Authored: Mon Feb 9 22:23:34 2015 +0100
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Mon Feb 9 22:23:34 2015 +0100

----------------------------------------------------------------------
 .../main/resources/findbugs/findbugs-exclude.xml |  9 ---------
 .../tamaya/resolver/internal/URLResolver.java    | 19 ++++++++++---------
 2 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cc1eda42/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
----------------------------------------------------------------------
diff --git a/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml b/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
index 3da23a4..b2264b3 100644
--- a/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
+++ b/buildconfigurations/src/main/resources/findbugs/findbugs-exclude.xml
@@ -79,9 +79,6 @@ under the License.
         <Class name="org.apache.tamaya.core.internal.PropertiesFileLoader"/>
     </Match>
     <Match>
-        <Class name="org.apache.tamaya.resolver.internal.URLResolver" />
-    </Match>
-    <Match>
         <Class name="org.apache.tamaya.resolver.internal.ResourceResolver" />
     </Match>
     <Match>
@@ -91,16 +88,10 @@ under the License.
         <Class name="org.apache.tamaya.resolver.internal.DefaultExpressionEvaluator" />
     </Match>
     <Match>
-        <Class name="org.apache.tamaya.inject.internal.Utils" />
-    </Match>
-    <Match>
         <Class name="org.apache.tamaya.inject.internal.ConfiguredSetterMethod" />
     </Match>
     <Match>
         <Class name="org.apache.tamaya.inject.internal.ConfigChangeCallbackMethod" />
     </Match>
-    <Match>
-        <Class name="org.apache.tamaya.inject.PropertyChangeSetBuilder" />
-    </Match>
 
 </FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cc1eda42/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
index 6d1d7d8..a1d042a 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
@@ -43,18 +43,19 @@ public final class URLResolver implements ExpressionResolver {
 
     @Override
     public String evaluate(String expression) {
-        BufferedReader in;
         try {
             URL url = new URL(expression);
-            in = new BufferedReader(
-                    new InputStreamReader(url.openStream()));
-            StringBuilder builder = new StringBuilder();
-            String inputLine;
-            while ((inputLine = in.readLine()) != null) {
-                builder.append(inputLine).append("\n");
+            try (InputStreamReader inputStreamReader = new InputStreamReader(url.openStream());
+                 BufferedReader bufferedReader = new BufferedReader(inputStreamReader))
+            {
+                StringBuilder builder = new StringBuilder();
+                String inputLine;
+                while ((inputLine = bufferedReader.readLine()) != null) {
+                    builder.append(inputLine).append("\n");
+                }
+
+                return builder.toString();
             }
-            in.close();
-            return builder.toString();
         } catch (Exception e) {
             LOG.log(Level.FINEST, "Could not resolve URL: " + expression, e);
             return null;


Mime
View raw message