From 4f6935aa25708f835b37042ca6dcd9fa567d63c0 Mon Sep 17 00:00:00 2001 From: Calvin Kirs Date: Wed, 9 Oct 2024 10:18:30 +0800 Subject: [PATCH] [chore](plugin) It's allowed for the plugin directory to be empty when loading plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When loading plugins, it's acceptable for the plugin directory to be empty. Users might create the directory without placing any plugins inside, but since some plugins are still located on the classpath, this doesn’t cause any issues. If users specify a particular plugin but don’t place it in the directory, the business logic should handle that situation. The general-purpose class shouldn’t be concerned with this. --- .../java/org/apache/doris/common/util/ClassLoaderUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/ClassLoaderUtils.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/ClassLoaderUtils.java index d0ebd26540159a..c82858c7d0132c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/ClassLoaderUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/ClassLoaderUtils.java @@ -22,6 +22,8 @@ import org.apache.doris.mysql.privilege.AccessControllerFactory; import org.apache.commons.collections.map.HashedMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -57,6 +59,7 @@ * @see ChildFirstClassLoader */ public class ClassLoaderUtils { + private static final Logger LOG = LogManager.getLogger(ClassLoaderUtils.class); // A mapping of service class simple names to their respective plugin directories. private static final Map pluginDirMapping = new HashedMap(); @@ -99,7 +102,8 @@ public static List loadServicesFromDirectory(Class serviceClass) throw File[] jarFiles = jarDir.listFiles((dir, name) -> name.endsWith(".jar")); if (jarFiles == null || jarFiles.length == 0) { - throw new IOException("No JAR files found in the specified directory: " + pluginDir); + LOG.info("No JAR files found in the plugin directory: {}", pluginDir); + return new ArrayList<>(); } List services = new ArrayList<>();