From 9bdef666cb5fd0aeee5083d5f92ce127a51e1a15 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sun, 15 Jan 2012 17:20:14 +0200 Subject: [PATCH] Plugin loading broken, closes #1610. --- .../org/elasticsearch/plugins/PluginsService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/elasticsearch/plugins/PluginsService.java b/src/main/java/org/elasticsearch/plugins/PluginsService.java index 1eae871796e..4f94f86983a 100644 --- a/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -245,18 +245,20 @@ public class PluginsService extends AbstractComponent { addURL.invoke(classLoader, pluginFile.toURI().toURL()); // gather files to add List libFiles = Lists.newArrayList(); - libFiles.addAll(Arrays.asList(pluginsFile.listFiles())); + if (pluginFile.listFiles() != null) { + libFiles.addAll(Arrays.asList(pluginFile.listFiles())); + } File libLocation = new File(pluginFile, "lib"); - if (libLocation.exists() && libLocation.isDirectory()) { + if (libLocation.exists() && libLocation.isDirectory() && libLocation.listFiles() != null) { libFiles.addAll(Arrays.asList(libLocation.listFiles())); } // if there are jars in it, add it as well - for (File jarToAdd : libFiles) { - if (!(jarToAdd.getName().endsWith(".jar") || jarToAdd.getName().endsWith(".zip"))) { + for (File libFile : libFiles) { + if (!(libFile.getName().endsWith(".jar") || libFile.getName().endsWith(".zip"))) { continue; } - addURL.invoke(classLoader, jarToAdd.toURI().toURL()); + addURL.invoke(classLoader, libFile.toURI().toURL()); } } catch (Exception e) { logger.warn("failed to add plugin [" + pluginFile + "]", e);