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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5da895ab08e Pipe: fix potential NPE risk when reflecting 
`pipeReceiverFileDirs` (#11346)
5da895ab08e is described below

commit 5da895ab08e833926f3036bd560ac1a2e87ba133
Author: V_Galaxy <[email protected]>
AuthorDate: Thu Oct 19 00:22:16 2023 +0800

    Pipe: fix potential NPE risk when reflecting `pipeReceiverFileDirs` (#11346)
    
    * fix: potential NPE risk when reflecting `pipeReceiverFileDirs`
    
    * chore: change ratis-thirdparty-misc dep scope for running DN
    
    org/apache/ratis/thirdparty/com/google/protobuf/ByteString
---
 iotdb-core/datanode/pom.xml                                |  2 +-
 .../main/java/org/apache/iotdb/db/conf/IoTDBConfig.java    |  6 +++---
 .../java/org/apache/iotdb/db/conf/IoTDBDescriptor.java     | 14 +++++++++-----
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/iotdb-core/datanode/pom.xml b/iotdb-core/datanode/pom.xml
index ef25d197894..363ca14d8ba 100644
--- a/iotdb-core/datanode/pom.xml
+++ b/iotdb-core/datanode/pom.xml
@@ -328,7 +328,7 @@
         <dependency>
             <groupId>org.apache.ratis</groupId>
             <artifactId>ratis-thirdparty-misc</artifactId>
-            <scope>test</scope>
+            <scope>runtime</scope>
         </dependency>
         <dependency>
             <groupId>com.nimbusds</groupId>
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 9c06c97e7d3..bdb33acc218 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -1080,8 +1080,8 @@ public class IoTDBConfig {
   private double maxMemoryRatioForQueue = 0.6;
 
   /** Pipe related */
-  /** initialized as null, updated based on the latest `systemDir` during 
querying */
-  private String[] pipeReceiverFileDirs = null;
+  /** initialized as empty, updated based on the latest `systemDir` during 
querying */
+  private String[] pipeReceiverFileDirs = new String[0];
 
   /** Resource control */
   private boolean quotaEnable = false;
@@ -3715,7 +3715,7 @@ public class IoTDBConfig {
   }
 
   public String[] getPipeReceiverFileDirs() {
-    return Objects.isNull(this.pipeReceiverFileDirs)
+    return (Objects.isNull(this.pipeReceiverFileDirs) || 
this.pipeReceiverFileDirs.length == 0)
         ? new String[] {systemDir + File.separator + "pipe" + File.separator + 
"receiver"}
         : this.pipeReceiverFileDirs;
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 5d43cfaa44e..c7cb82dcef3 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -71,6 +71,7 @@ import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 import java.util.ServiceLoader;
@@ -1987,11 +1988,14 @@ public class IoTDBDescriptor {
     conf.setPipeLibDir(properties.getProperty("pipe_lib_dir", 
conf.getPipeLibDir()));
 
     conf.setPipeReceiverFileDirs(
-        properties
-            .getProperty(
-                "pipe_receiver_file_dirs", String.join(",", 
conf.getPipeReceiverFileDirs()))
-            .trim()
-            .split(","));
+        Arrays.stream(
+                properties
+                    .getProperty(
+                        "pipe_receiver_file_dirs", String.join(",", 
conf.getPipeReceiverFileDirs()))
+                    .trim()
+                    .split(","))
+            .filter(dir -> !dir.isEmpty())
+            .toArray(String[]::new));
   }
 
   private void loadCQProps(Properties properties) {

Reply via email to