Skip to content

Commit

Permalink
NPE in PluginManager when asking for list on non existing dir
Browse files Browse the repository at this point in the history
Asking for list of installed plugins with no existing plugin dir:

```sh
$ bin/plugin --list
```

It causes a NPE in PluginManager.
Closes elastic#3253.
  • Loading branch information
dadoonet committed Jun 27, 2013
1 parent 05158c4 commit 88026fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/elasticsearch/plugins/PluginManager.java
Expand Up @@ -297,12 +297,12 @@ public void removePlugin(String name) throws IOException {
public void listInstalledPlugins() {
File[] plugins = environment.pluginsFile().listFiles();
System.out.println("Installed plugins:");
if (plugins.length == 0) {
if (plugins == null || plugins.length == 0) {
System.out.println(" - No plugin detected in " + environment.pluginsFile().getAbsolutePath());
}

for (int i = 0; i < plugins.length; i++) {
System.out.println(" - " + plugins[i].getName());
} else {
for (int i = 0; i < plugins.length; i++) {
System.out.println(" - " + plugins[i].getName());
}
}
}

Expand Down

0 comments on commit 88026fa

Please sign in to comment.