You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/12/08 00:47:07 UTC

[iotdb] branch master updated: ListFileInExtPipePluginRegister (#8372)

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

haonan 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 e06900546e ListFileInExtPipePluginRegister (#8372)
e06900546e is described below

commit e06900546e621324ee4524894a5d593f81fa93bc
Author: yschengzi <87...@users.noreply.github.com>
AuthorDate: Thu Dec 8 08:46:59 2022 +0800

    ListFileInExtPipePluginRegister (#8372)
---
 .../db/sync/externalpipe/ExtPipePluginRegister.java      | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/sync/externalpipe/ExtPipePluginRegister.java b/server/src/main/java/org/apache/iotdb/db/sync/externalpipe/ExtPipePluginRegister.java
index aabbdc9904..19c6328baa 100644
--- a/server/src/main/java/org/apache/iotdb/db/sync/externalpipe/ExtPipePluginRegister.java
+++ b/server/src/main/java/org/apache/iotdb/db/sync/externalpipe/ExtPipePluginRegister.java
@@ -29,13 +29,17 @@ import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /** ExtPipePluginRegister is used to manage the all External Pipe Plugin info. */
 public class ExtPipePluginRegister {
@@ -75,11 +79,17 @@ public class ExtPipePluginRegister {
     FileUtils.forceMkdir(file);
   }
 
+  private Collection<File> findAllJar(File directory) {
+    try (Stream<File> stream = FileUtils.streamFiles(directory, true, "jar")) {
+      return stream.collect(Collectors.toList());
+    } catch (IOException e) {
+      throw new UncheckedIOException(directory.toString(), e);
+    }
+  }
+
   private URL[] getPlugInJarURLs() throws IOException {
     HashSet<File> fileSet =
-        new HashSet<>(
-            FileUtils.listFiles(
-                SystemFileFactory.INSTANCE.getFile(extPipeDir), new String[] {"jar"}, true));
+        new HashSet<>(findAllJar(SystemFileFactory.INSTANCE.getFile(extPipeDir)));
     return FileUtils.toURLs(fileSet.toArray(new File[0]));
   }