From 6574243077a336c189edefa42be3ad2893d69b6b Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 22 Jun 2016 12:03:11 -0400 Subject: [PATCH] Fail to start if plugin tries broken onModule If a plugin declares `onModule(SomethingThatIsntAModule)` then refuse to start. Before this commit we just logged a warning that flies by in the console and is easy to miss. You can't miss refusing to start! --- .../java/org/elasticsearch/plugins/PluginsService.java | 10 ++++++++-- docs/reference/migration/migrate_5_0/plugins.asciidoc | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java index 9b983fa2931..71081740d33 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -44,6 +44,7 @@ import org.elasticsearch.index.IndexModule; import org.elasticsearch.script.NativeScriptFactory; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptEngineService; +import org.elasticsearch.script.ScriptModule; import org.elasticsearch.threadpool.ExecutorBuilder; import java.io.IOException; @@ -206,8 +207,13 @@ public class PluginsService extends AbstractComponent { } Class moduleClass = method.getParameterTypes()[0]; if (!Module.class.isAssignableFrom(moduleClass)) { - logger.warn("Plugin: {} implementing onModule by the type is not of Module type {}", pluginEntry.v1().getName(), moduleClass); - continue; + if (moduleClass == ScriptModule.class) { + // This is still part of the Plugin class to point the user to the new implementation + continue; + } + throw new RuntimeException( + "Plugin: [" + pluginEntry.v1().getName() + "] implements onModule taking a parameter that isn't a Module [" + + moduleClass.getSimpleName() + "]"); } list.add(new OnModuleReference(moduleClass, method)); } diff --git a/docs/reference/migration/migrate_5_0/plugins.asciidoc b/docs/reference/migration/migrate_5_0/plugins.asciidoc index 1578ae074df..a1c0dad9ca1 100644 --- a/docs/reference/migration/migrate_5_0/plugins.asciidoc +++ b/docs/reference/migration/migrate_5_0/plugins.asciidoc @@ -117,3 +117,8 @@ via ES_JAVA_OPTS. The ability to specify a custom plugins path via `path.plugins` has been removed. + +==== ScriptPlugin + +Plugins that register custom scripts should implement `ScriptPlugin` and remove +their `onModule(ScriptModule)` implementation.