You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2018/12/26 06:49:30 UTC

[GitHub] shaofengshi closed pull request #416: KYLIN-3597 fix sonar issues

shaofengshi closed pull request #416: KYLIN-3597 fix sonar issues
URL: https://github.com/apache/kylin/pull/416
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 dc3a45b00f..9e5a9898e1 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 void execute(Connection connection) throws SQLException, IOException {
                             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 @@ private boolean isContentOverflow(byte[] content, String resPath) throws SQLExce
 
             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 void execute(Connection connection) throws SQLException, IOException {
                                 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 void execute(Connection connection) throws SQLException, IOException {
                                     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 void execute(Connection connection) throws SQLException {
             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 d4c6d0c77e..3ff06947e4 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.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 @@ void onRetry(int errorResourceCnt) {
 
     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();
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services