This is an automated email from the ASF dual-hosted git repository.

shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new e1ba10a  KYLIN-3597 fix sonar issues
e1ba10a is described below

commit e1ba10ab4f0bfbea3abd1aed1860c81762aca91a
Author: Lijun Cao <641507...@qq.com>
AuthorDate: Wed Dec 26 11:35:42 2018 +0800

    KYLIN-3597 fix sonar issues
---
 .../kylin/common/persistence/JDBCResourceStore.java       | 15 +++++++--------
 .../org/apache/kylin/common/persistence/ResourceTool.java | 12 ++++--------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git 
a/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceStore.java
 
b/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceStore.java
index dc3a45b..9e5a989 100644
--- 
a/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceStore.java
+++ 
b/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceStore.java
@@ -378,9 +378,9 @@ public class JDBCResourceStore extends 
PushdownResourceStore {
                             int result = pstat.executeUpdate();
                             if (result != 1)
                                 throw new SQLException();
-                        } catch (Throwable ex) {
+                        } catch (Exception e) {
                             pushdown.rollback();
-                            throw ex;
+                            throw e;
                         } finally {
                             pushdown.close();
                         }
@@ -400,9 +400,8 @@ public class JDBCResourceStore extends 
PushdownResourceStore {
 
             if (content.length > smallCellMetadataWarningThreshold) {
                 logger.warn(
-                        "A JSON metadata entry's size is not supposed to 
exceed kap.metadata.jdbc.small-cell-meta-size-warning-threshold("
-                                + smallCellMetadataWarningThreshold + "), 
resPath: " + resPath + ", actual size: "
-                                + content.length);
+                        "A JSON metadata entry's size is not supposed to 
exceed kap.metadata.jdbc.small-cell-meta-size-warning-threshold({}), resPath: 
{}, actual size: {}",
+                        smallCellMetadataWarningThreshold, resPath, 
content.length);
             }
             if (content.length > smallCellMetadataErrorThreshold) {
                 throw new SQLException(new IllegalArgumentException(
@@ -457,7 +456,7 @@ public class JDBCResourceStore extends 
PushdownResourceStore {
                                 int result = pstat.executeUpdate();
                                 if (result != 1)
                                     throw new SQLException();
-                            } catch (Throwable e) {
+                            } catch (Exception e) {
                                 pushdown.rollback();
                                 throw e;
                             } finally {
@@ -496,7 +495,7 @@ public class JDBCResourceStore extends 
PushdownResourceStore {
                                     int result2 = pstat2.executeUpdate();
                                     if (result2 != 1)
                                         throw new SQLException();
-                                } catch (Throwable e) {
+                                } catch (Exception e) {
                                     pushdown.rollback();
                                     throw e;
                                 } finally {
@@ -535,7 +534,7 @@ public class JDBCResourceStore extends 
PushdownResourceStore {
             if (!skipHdfs) {
                 try {
                     deletePushdown(resPath);
-                } catch (Throwable e) {
+                } catch (Exception e) {
                     throw new SQLException(e);
                 }
             }
diff --git 
a/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
 
b/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
index d4c6d0c..3ff0694 100644
--- 
a/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
+++ 
b/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
@@ -29,7 +29,6 @@ import java.util.NavigableSet;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.persistence.ResourceParallelCopier.Stats;
 import org.apache.kylin.common.util.StringUtil;
@@ -176,20 +175,17 @@ public class ResourceTool {
 
     public String cat(KylinConfig config, String path) throws IOException {
         ResourceStore store = ResourceStore.getStore(config);
-        InputStream is = store.getResource(path).content();
-        BufferedReader br = null;
         StringBuffer sb = new StringBuffer();
         String line;
-        try {
-            br = new BufferedReader(new InputStreamReader(is, 
StandardCharsets.UTF_8));
+
+        try (InputStream is = store.getResource(path).content();
+                BufferedReader br = new BufferedReader(new 
InputStreamReader(is, StandardCharsets.UTF_8))) {
             while ((line = br.readLine()) != null) {
                 System.out.println(line);
                 sb.append(line).append('\n');
             }
-        } finally {
-            IOUtils.closeQuietly(is);
-            IOUtils.closeQuietly(br);
         }
+
         return sb.toString();
     }
 

Reply via email to