You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by er...@apache.org on 2022/08/19 04:13:44 UTC

[iotdb] branch bugfix/iotdb-4187 created (now f4f51b9a9d)

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

ericpai pushed a change to branch bugfix/iotdb-4187
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at f4f51b9a9d [IOTDB-4187] Fix potential NPE in IoTDBConfig

This branch includes the following new commits:

     new f4f51b9a9d [IOTDB-4187] Fix potential NPE in IoTDBConfig

The 1 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.



[iotdb] 01/01: [IOTDB-4187] Fix potential NPE in IoTDBConfig

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ericpai pushed a commit to branch bugfix/iotdb-4187
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit f4f51b9a9d61da48a6b2176261273c750cc5175e
Author: ericpai <er...@hotmail.com>
AuthorDate: Fri Aug 19 12:13:30 2022 +0800

    [IOTDB-4187] Fix potential NPE in IoTDBConfig
---
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 3ee6e92b35..a5edcca7d5 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -3068,7 +3068,7 @@ public class IoTDBConfig {
   }
 
   public String getConfigMessage() {
-    String configMessage = "";
+    StringBuilder configMessage = new StringBuilder();
     String configContent;
     String[] notShowArray = {
       "NODE_NAME_MATCHER",
@@ -3085,18 +3085,23 @@ public class IoTDBConfig {
         if (notShowStrings.contains(configFieldString)) {
           continue;
         }
-        String configType = configField.getGenericType().getTypeName();
-        if (configType.contains("java.lang.String[]")) {
-          String[] configList = (String[]) configField.get(this);
-          configContent = Arrays.asList(configList).toString();
+        Object obj = configField.get(this);
+        if (obj != null) {
+          String configType = configField.getGenericType().getTypeName();
+          if (configType.contains("java.lang.String[]")) {
+            String[] configList = (String[]) obj;
+            configContent = Arrays.asList(configList).toString();
+          } else {
+            configContent = obj.toString();
+          }
         } else {
-          configContent = configField.get(this).toString();
+          configContent = null;
         }
-        configMessage = configMessage + configField.getName() + "=" + configContent + "; ";
+        configMessage.append(configField.getName()).append("=").append(configContent).append("; ");
       } catch (Exception e) {
-        e.printStackTrace();
+        logger.error("Printing configuration field [{}] failed ", configField.getName(), e);
       }
     }
-    return configMessage;
+    return configMessage.toString();
   }
 }