You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/02/09 02:31:25 UTC
[12/39] kylin git commit: KYLIN-2391 Unclosed FileInputStream in
KylinConfig#getConfigAsString()
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/6f0bc1c3
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/6f0bc1c3
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/6f0bc1c3
Branch: refs/heads/master-hbase0.98
Commit: 6f0bc1c3edd75f0b180afeeb68e09cf01298d4d8
Parents: 56a3e6c
Author: shaofengshi <sh...@apache.org>
Authored: Sat Feb 4 19:35:12 2017 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Sat Feb 4 19:37:59 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/6f0bc1c3/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() {