You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2018/12/10 13:54:24 UTC

[kylin] branch master updated (684f21c -> 497cdf0)

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

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


    from 684f21c  KYLIN-3671 Improve ResourceTool and JDBCResourceStore's performance
     new 4e171c8  KYLIN-3597 fix snoar issues
     new 497cdf0  KYLIN-3597 fix sonar issues

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../kylin/common/BackwardCompatibilityConfig.java  | 11 ++---------
 .../java/org/apache/kylin/common/KylinConfig.java  | 22 ++++++++--------------
 2 files changed, 10 insertions(+), 23 deletions(-)


[kylin] 02/02: KYLIN-3597 fix sonar issues

Posted by sh...@apache.org.
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

commit 497cdf0c3bf0bee3bcc1c9d9ff21b0a00448f42e
Author: whuwb <sk...@gmail.com>
AuthorDate: Mon Dec 10 19:53:50 2018 +0800

    KYLIN-3597 fix sonar issues
---
 core-common/src/main/resources/kylin-defaults.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core-common/src/main/resources/kylin-defaults.properties b/core-common/src/main/resources/kylin-defaults.properties
index ee824bf..6f2db9a 100644
--- a/core-common/src/main/resources/kylin-defaults.properties
+++ b/core-common/src/main/resources/kylin-defaults.properties
@@ -91,7 +91,7 @@ kylin.source.hive.beeline-shell=beeline
 # While hive client uses above settings to read hive table metadata,
 # table operations can go through a separate SparkSQL command line, given SparkSQL connects to the same Hive metastore.
 kylin.source.hive.enable-sparksql-for-table-ops=false
-#kylin.source.hive.sparksql-beeline-shell=/path/to/spark-client/bin/bee
+#kylin.source.hive.sparksql-beeline-shell=/path/to/spark-client/bin/beeline
 #kylin.source.hive.sparksql-beeline-params=-n root --hiveconf hive.security.authorization.sqlstd.confwhitelist.append='mapreduce.job.*|dfs.*' -u jdbc:hive2://localhost:10000
 
 kylin.source.hive.keep-flat-table=false


[kylin] 01/02: KYLIN-3597 fix snoar issues

Posted by sh...@apache.org.
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

commit 4e171c8b0fbcd7a6ffaa24e62a12dd7a070ccd49
Author: whuwb <sk...@gmail.com>
AuthorDate: Mon Dec 10 16:20:05 2018 +0800

    KYLIN-3597 fix snoar issues
---
 .../kylin/common/BackwardCompatibilityConfig.java  | 11 ++---------
 .../java/org/apache/kylin/common/KylinConfig.java  | 22 ++++++++--------------
 .../src/main/resources/kylin-defaults.properties   |  2 +-
 3 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/core-common/src/main/java/org/apache/kylin/common/BackwardCompatibilityConfig.java b/core-common/src/main/java/org/apache/kylin/common/BackwardCompatibilityConfig.java
index aeb7636..751d2f7 100644
--- a/core-common/src/main/java/org/apache/kylin/common/BackwardCompatibilityConfig.java
+++ b/core-common/src/main/java/org/apache/kylin/common/BackwardCompatibilityConfig.java
@@ -144,26 +144,21 @@ public class BackwardCompatibilityConfig {
         BackwardCompatibilityConfig bcc = new BackwardCompatibilityConfig();
         File repoDir = new File(kylinRepoPath).getCanonicalFile();
         File outputDir = new File(outputPath).getCanonicalFile();
-        PrintWriter out = null;
 
         // generate sed file
         File sedFile = new File(outputDir, "upgrade-old-config.sed");
-        try {
-            out = new PrintWriter(sedFile, "UTF-8");
+        try (PrintWriter out = new PrintWriter(sedFile, "UTF-8")) {
             for (Entry<String, String> e : bcc.old2new.entrySet()) {
                 out.println("s/" + quote(e.getKey()) + "/" + e.getValue() + "/g");
             }
             for (Entry<String, String> e : bcc.old2newPrefix.entrySet()) {
                 out.println("s/" + quote(e.getKey()) + "/" + e.getValue() + "/g");
             }
-        } finally {
-            IOUtils.closeQuietly(out);
         }
 
         // generate sh file
         File shFile = new File(outputDir, "upgrade-old-config.sh");
-        try {
-            out = new PrintWriter(shFile, "UTF-8");
+        try (PrintWriter out = new PrintWriter(shFile, "UTF-8")) {
             out.println("#!/bin/bash");
             Stack<File> stack = new Stack<>();
             stack.push(repoDir);
@@ -179,8 +174,6 @@ public class BackwardCompatibilityConfig {
                         out.println("sed -i -f upgrade-old-config.sed " + f.getAbsolutePath());
                 }
             }
-        } finally {
-            IOUtils.closeQuietly(out);
         }
 
         System.out.println("Files generated:");
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 4a86b76..4db1748 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
@@ -50,6 +50,7 @@ import com.google.common.base.Preconditions;
 public class KylinConfig extends KylinConfigBase {
     private static final long serialVersionUID = 1L;
     private static final Logger logger = LoggerFactory.getLogger(KylinConfig.class);
+    private static final String METADATA_URI_PREFIX = "Metadata uri : ";
 
     /**
      * Kylin properties file name
@@ -192,20 +193,20 @@ public class KylinConfig extends KylinConfigBase {
                         return UriType.PROPERTIES_FILE;
                     } else {
                         throw new IllegalStateException(
-                                "Metadata uri : " + metaUri + " is a local file but not kylin.properties");
+                                METADATA_URI_PREFIX + metaUri + " is a local file but not kylin.properties");
                     }
                 } else {
                     throw new IllegalStateException(
-                            "Metadata uri : " + metaUri + " looks like a file but it's neither a file nor a directory");
+                            METADATA_URI_PREFIX + metaUri + " looks like a file but it's neither a file nor a directory");
                 }
             } else {
                 if (RestClient.matchFullRestPattern(metaUri))
                     return UriType.REST_ADDR;
                 else
-                    throw new IllegalStateException("Metadata uri : " + metaUri + " is not a valid REST URI address");
+                    throw new IllegalStateException(METADATA_URI_PREFIX + metaUri + " is not a valid REST URI address");
             }
         } catch (Exception e) {
-            throw new IllegalStateException("Metadata uri : " + metaUri + " is not recognized", e);
+            throw new IllegalStateException(METADATA_URI_PREFIX + metaUri + " is not recognized", e);
         }
     }
 
@@ -393,9 +394,8 @@ public class KylinConfig extends KylinConfigBase {
      */
     private static void loadPropertiesFromInputStream(InputStream inputStream, OrderedProperties properties) {
         Preconditions.checkNotNull(properties);
-        BufferedReader confReader = null;
-        try {
-            confReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+
+        try (BufferedReader confReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) {
             OrderedProperties temp = new OrderedProperties();
             temp.load(confReader);
             temp = BCC.check(temp);
@@ -403,8 +403,6 @@ public class KylinConfig extends KylinConfigBase {
             properties.putAll(temp);
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            IOUtils.closeQuietly(confReader);
         }
     }
 
@@ -521,12 +519,8 @@ public class KylinConfig extends KylinConfigBase {
     }
 
     public void exportToFile(File file) throws IOException {
-        FileOutputStream fos = null;
-        try {
-            fos = new FileOutputStream(file);
+        try (FileOutputStream fos = new FileOutputStream(file)) {
             getAllProperties().store(fos, file.getAbsolutePath());
-        } finally {
-            IOUtils.closeQuietly(fos);
         }
     }
 
diff --git a/core-common/src/main/resources/kylin-defaults.properties b/core-common/src/main/resources/kylin-defaults.properties
index 6f2db9a..ee824bf 100644
--- a/core-common/src/main/resources/kylin-defaults.properties
+++ b/core-common/src/main/resources/kylin-defaults.properties
@@ -91,7 +91,7 @@ kylin.source.hive.beeline-shell=beeline
 # While hive client uses above settings to read hive table metadata,
 # table operations can go through a separate SparkSQL command line, given SparkSQL connects to the same Hive metastore.
 kylin.source.hive.enable-sparksql-for-table-ops=false
-#kylin.source.hive.sparksql-beeline-shell=/path/to/spark-client/bin/beeline
+#kylin.source.hive.sparksql-beeline-shell=/path/to/spark-client/bin/bee
 #kylin.source.hive.sparksql-beeline-params=-n root --hiveconf hive.security.authorization.sqlstd.confwhitelist.append='mapreduce.job.*|dfs.*' -u jdbc:hive2://localhost:10000
 
 kylin.source.hive.keep-flat-table=false