Skip to content

Commit

Permalink
[chore](plugin)
Browse files Browse the repository at this point in the history
It's allowed for the plugin directory to be empty when loading plugins

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.
  • Loading branch information
CalvinKirs committed Oct 9, 2024
1 parent 4562b9a commit 4f6935a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> pluginDirMapping = new HashedMap();

Expand Down Expand Up @@ -99,7 +102,8 @@ public static <T> List<T> loadServicesFromDirectory(Class<T> 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<T> services = new ArrayList<>();
Expand Down

0 comments on commit 4f6935a

Please sign in to comment.