Browse Source

Fix optional default script loading
Groovy is optional as a dependency in the classpath, make sure we properly detect when its not at the right time to disable it
closes #6582

Shay Banon 11 năm trước cách đây
mục cha
commit
0d66d3779e
1 tập tin đã thay đổi với 6 bổ sung3 xóa
  1. 6 3
      src/main/java/org/elasticsearch/script/ScriptModule.java

+ 6 - 3
src/main/java/org/elasticsearch/script/ScriptModule.java

@@ -80,21 +80,24 @@ public class ScriptModule extends AbstractModule {
         multibinder.addBinding().to(NativeScriptEngineService.class);
 
         try {
+            settings.getClassLoader().loadClass("groovy.lang.GroovyClassLoader");
             multibinder.addBinding().to(GroovyScriptEngineService.class);
         } catch (Throwable t) {
-            Loggers.getLogger(GroovyScriptEngineService.class).debug("failed to load groovy", t);
+            Loggers.getLogger(ScriptService.class, settings).debug("failed to load groovy", t);
         }
 
         try {
+            settings.getClassLoader().loadClass("org.mvel2.MVEL");
             multibinder.addBinding().to(MvelScriptEngineService.class);
         } catch (Throwable t) {
-            Loggers.getLogger(MvelScriptEngineService.class).debug("failed to load mvel", t);
+            Loggers.getLogger(ScriptService.class, settings).debug("failed to load mvel", t);
         }
         
         try {
+            settings.getClassLoader().loadClass("com.github.mustachejava.Mustache");
             multibinder.addBinding().to(MustacheScriptEngineService.class);
         } catch (Throwable t) {
-            Loggers.getLogger(MustacheScriptEngineService.class).debug("failed to load mustache", t);
+            Loggers.getLogger(ScriptService.class, settings).debug("failed to load mustache", t);
         }
 
         for (Class<? extends ScriptEngineService> scriptEngine : scriptEngines) {