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!
This commit is contained in:
parent
6d04c1e78e
commit
6574243077
|
@ -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,9 +207,14 @@ 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);
|
||||
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));
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue