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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9a20ac7  [CARBONDATA-3521] optimize read property file code
9a20ac7 is described below

commit 9a20ac7c314a370af2bfdc1b82849aa76087d71f
Author: lamber-ken <[email protected]>
AuthorDate: Tue Sep 17 02:29:14 2019 +0800

    [CARBONDATA-3521] optimize read property file code
    
    1. change System.getProperty(key) to System.getProperty(key, default)
    2. optimize duplicated code, like CARBON_PROPERTIES_FILE_PATH_DEFAULT
    
    This closes #3391
---
 .../carbondata/core/util/CarbonProperties.java     | 28 ++++++++--------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git 
a/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java 
b/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
index e4efc0b..80882e8 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/CarbonProperties.java
@@ -757,38 +757,30 @@ public final class CarbonProperties {
    * memory
    */
   private void loadProperties() {
-    String property = 
System.getProperty(CarbonCommonConstants.CARBON_PROPERTIES_FILE_PATH);
-    if (null == property) {
-      property = CarbonCommonConstants.CARBON_PROPERTIES_FILE_PATH_DEFAULT;
-    }
-    File file = new File(property);
-    LOGGER.info("Property file path: " + file.getAbsolutePath());
+    String propertyPath = 
System.getProperty(CarbonCommonConstants.CARBON_PROPERTIES_FILE_PATH,
+            CarbonCommonConstants.CARBON_PROPERTIES_FILE_PATH_DEFAULT);
+
+    File propertyFile = new File(propertyPath);
+    LOGGER.info("Property file path: " + propertyFile.getAbsolutePath());
 
     FileInputStream fis = null;
     try {
-      if (file.exists()) {
-        fis = new FileInputStream(file);
+      if (propertyFile.exists()) {
+        fis = new FileInputStream(propertyFile);
 
         carbonProperties.load(fis);
       }
     } catch (FileNotFoundException e) {
-      LOGGER.error(
-          "The file: " + FileFactory.getCarbonFile(CarbonCommonConstants
-              .CARBON_PROPERTIES_FILE_PATH_DEFAULT).getAbsolutePath()
-              + " does not exist");
+      LOGGER.error("The file: " + propertyFile.getAbsolutePath() + " does not 
exist");
     } catch (IOException e) {
-      LOGGER.error(
-          "Error while reading the file: "
-              + FileFactory.getCarbonFile(CarbonCommonConstants
-              .CARBON_PROPERTIES_FILE_PATH_DEFAULT).getAbsolutePath());
+      LOGGER.error("Error while reading the file: " + 
propertyFile.getAbsolutePath());
     } finally {
       if (null != fis) {
         try {
           fis.close();
         } catch (IOException e) {
           LOGGER.error("Error while closing the file stream for file: "
-              + FileFactory.getCarbonFile(CarbonCommonConstants
-              .CARBON_PROPERTIES_FILE_PATH_DEFAULT).getAbsolutePath());
+              + propertyFile.getAbsolutePath());
         }
       }
     }

Reply via email to