kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaofeng...@apache.org
Subject kylin git commit: KYLIN-2391 Unclosed FileInputStream in KylinConfig#getConfigAsString()
Date Sat, 04 Feb 2017 11:37:39 GMT
Repository: kylin
Updated Branches:
  refs/heads/spark-it b55250e24 -> 4a98b26f4


KYLIN-2391 Unclosed FileInputStream in KylinConfig#getConfigAsString()


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/4a98b26f
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/4a98b26f
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/4a98b26f

Branch: refs/heads/spark-it
Commit: 4a98b26f4dd0e9afb233d43687fe522c99077127
Parents: b55250e
Author: shaofengshi <shaofengshi@apache.org>
Authored: Sat Feb 4 19:35:12 2017 +0800
Committer: shaofengshi <shaofengshi@apache.org>
Committed: Sat Feb 4 19:35:12 2017 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/common/KylinConfig.java    | 21 ++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/4a98b26f/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
index 4eac92a..0f40654 100644
--- a/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
+++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
@@ -296,15 +296,20 @@ public class KylinConfig extends KylinConfigBase {
     }
 
     public String getConfigAsString() throws IOException {
-        File propertiesFile = getKylinPropertiesFile();
-        OrderedProperties orderedProperties = new OrderedProperties();
-        orderedProperties.load(new FileInputStream(propertiesFile));
-        orderedProperties = BCC.check(orderedProperties);
-        final StringBuilder sb = new StringBuilder();
-        for (Map.Entry<String, String> entry : orderedProperties.entrySet()) {
-            sb.append(entry.getKey() + "=" + entry.getValue()).append('\n');
+        final File propertiesFile = getKylinPropertiesFile();
+        final InputStream is = new FileInputStream(propertiesFile);
+        try {
+            OrderedProperties orderedProperties = new OrderedProperties();
+            orderedProperties.load(is);
+            orderedProperties = BCC.check(orderedProperties);
+            final StringBuilder sb = new StringBuilder();
+            for (Map.Entry<String, String> entry : orderedProperties.entrySet()) {
+                sb.append(entry.getKey() + "=" + entry.getValue()).append('\n');
+            }
+            return sb.toString();
+        } finally {
+            IOUtils.closeQuietly(is);
         }
-        return sb.toString();
     }
 
     public KylinConfig base() {


Mime
View raw message