Browse Source

Deprecate Groovy, Python, and Javascript scripts.

Jack Conradson 9 years ago
parent
commit
7930233527

+ 2 - 0
docs/plugins/lang-javascript.asciidoc

@@ -1,6 +1,8 @@
 [[lang-javascript]]
 === JavaScript Language Plugin
 
+deprecated[5.0.0,Javascript will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
+
 The JavaScript language plugin enables the use of JavaScript in Elasticsearch
 scripts, via Mozilla's
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino[Rhino JavaScript] engine.

+ 2 - 0
docs/plugins/lang-python.asciidoc

@@ -1,6 +1,8 @@
 [[lang-python]]
 === Python Language Plugin
 
+deprecated[5.0.0,Python will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
+
 The Python language plugin enables the use of Python in Elasticsearch
 scripts, via the http://www.jython.org/[Jython] Java implementation of Python.
 

+ 1 - 6
docs/reference/modules/scripting.asciidoc

@@ -5,12 +5,7 @@ The scripting module enables you to use scripts to evaluate custom
 expressions. For example, you could use a script to return "script fields"
 as part of a search request or evaluate a custom score for a query.
 
-TIP: Elasticsearch now has a built-in scripting language called _Painless_
-that provides a more secure alternative for implementing
-scripts for Elasticsearch. We encourage you to try it out --
-for more information, see <<modules-scripting-painless, Painless Scripting Language>>.
-
-The default scripting language is http://groovy-lang.org/[groovy].
+The default scripting language is <<modules-scripting-painless, `Painless`>>.
 Additional `lang` plugins enable you to run scripts written in other languages.
 Everywhere a script can be used, you can include a `lang` parameter
 to specify the language of the script.

+ 2 - 0
docs/reference/modules/scripting/groovy.asciidoc

@@ -1,6 +1,8 @@
 [[modules-scripting-groovy]]
 === Groovy Scripting Language
 
+deprecated[5.0.0,Groovy will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
+
 Groovy is the default scripting language available in Elasticsearch.  Although
 limited by the <<java-security-manager,Java Security Manager>>, it is not a
 sandboxed language and only `file` scripts may be used by default.

+ 10 - 0
modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java

@@ -68,6 +68,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import static java.util.Collections.emptyList;
 
@@ -91,6 +92,11 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
      */
     private final ClassLoader loader;
 
+    /**
+     * Ensures that the deprecation log entry for Groovy is only written on the first Groovy script compiled.
+     */
+    private AtomicBoolean isDeprecationLogged = new AtomicBoolean(false);
+
     public GroovyScriptEngineService(Settings settings) {
         super(settings);
         // Creates the classloader here in order to isolate Groovy-land code
@@ -134,6 +140,10 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
 
     @Override
     public Object compile(String scriptName, String scriptSource, Map<String, String> params) {
+        if (isDeprecationLogged.compareAndSet(false, true)) {
+            deprecationLogger.deprecated("Groovy scripts are deprecated.  Use Painless scripts instead.");
+        }
+
         // Create the script class name
         String className = MessageDigests.toHexString(MessageDigests.sha1().digest(scriptSource.getBytes(StandardCharsets.UTF_8)));
 

+ 3 - 0
plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java

@@ -25,6 +25,7 @@ import org.elasticsearch.SpecialPermission;
 import org.elasticsearch.bootstrap.BootstrapInfo;
 import org.elasticsearch.common.Nullable;
 import org.elasticsearch.common.component.AbstractComponent;
+import org.elasticsearch.common.logging.DeprecationLogger;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.script.ClassPermission;
 import org.elasticsearch.script.CompiledScript;
@@ -138,6 +139,8 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
     public JavaScriptScriptEngineService(Settings settings) {
         super(settings);
 
+        deprecationLogger.deprecated("Javascript scripts are deprecated.  Use Painless scripts instead.");
+
         Context ctx = Context.enter();
         try {
             globalScope = ctx.initStandardObjects(null, true);

+ 2 - 0
plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java

@@ -62,6 +62,8 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
     public PythonScriptEngineService(Settings settings) {
         super(settings);
 
+        deprecationLogger.deprecated("Python scripts are deprecated.  Use Painless scripts instead.");
+
         // classloader created here
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {