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.NativeScriptFactory;
|
||||||
import org.elasticsearch.script.ScriptContext;
|
import org.elasticsearch.script.ScriptContext;
|
||||||
import org.elasticsearch.script.ScriptEngineService;
|
import org.elasticsearch.script.ScriptEngineService;
|
||||||
|
import org.elasticsearch.script.ScriptModule;
|
||||||
import org.elasticsearch.threadpool.ExecutorBuilder;
|
import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -206,8 +207,13 @@ public class PluginsService extends AbstractComponent {
|
||||||
}
|
}
|
||||||
Class moduleClass = method.getParameterTypes()[0];
|
Class moduleClass = method.getParameterTypes()[0];
|
||||||
if (!Module.class.isAssignableFrom(moduleClass)) {
|
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) {
|
||||||
continue;
|
// 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));
|
list.add(new OnModuleReference(moduleClass, method));
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,3 +117,8 @@ via ES_JAVA_OPTS.
|
||||||
|
|
||||||
The ability to specify a custom plugins path via `path.plugins` has
|
The ability to specify a custom plugins path via `path.plugins` has
|
||||||
been removed.
|
been removed.
|
||||||
|
|
||||||
|
==== ScriptPlugin
|
||||||
|
|
||||||
|
Plugins that register custom scripts should implement `ScriptPlugin` and remove
|
||||||
|
their `onModule(ScriptModule)` implementation.
|
||||||
|
|
Loading…
Reference in New Issue