Browse Source

Made deprecation of Groovy, Javascript, and Python more explicit.

Jack Conradson 9 years ago
parent
commit
3b3baa6e6c

+ 1 - 1
docs/plugins/lang-javascript.asciidoc

@@ -1,7 +1,7 @@
 [[lang-javascript]]
 === JavaScript Language Plugin
 
-deprecated[5.0.0,Javascript will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
+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

+ 0 - 1
docs/reference/modules/scripting/using.asciidoc

@@ -201,7 +201,6 @@ POST _scripts/groovy/calculate-score
 }
 -----------------------------------
 // CONSOLE
-// TEST[warning:Groovy scripts are deprecated.  Use Painless scripts instead.]
 
 This same script can be retrieved with:
 

+ 7 - 9
modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java

@@ -92,13 +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);
+
+        deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead");
+
         // Creates the classloader here in order to isolate Groovy-land code
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
@@ -140,10 +138,6 @@ 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)));
 
@@ -189,6 +183,8 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
 
     @Override
     public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> vars) {
+        deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead");
+
         try {
             Map<String, Object> allVars = new HashMap<>();
             if (vars != null) {
@@ -202,6 +198,8 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
 
     @Override
     public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
+        deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead");
+
         return new SearchScript() {
 
             @Override

+ 5 - 1
plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java

@@ -139,7 +139,7 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
     public JavaScriptScriptEngineService(Settings settings) {
         super(settings);
 
-        deprecationLogger.deprecated("Javascript scripts are deprecated.  Use Painless scripts instead.");
+        deprecationLogger.deprecated("[javascript] scripts are deprecated, use [painless] scripts instead");
 
         Context ctx = Context.enter();
         try {
@@ -176,6 +176,8 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
 
     @Override
     public ExecutableScript executable(CompiledScript compiledScript, @Nullable Map<String, Object> vars) {
+        deprecationLogger.deprecated("[javascript] scripts are deprecated, use [painless] scripts instead");
+
         Context ctx = Context.enter();
         try {
             Scriptable scope = ctx.newObject(globalScope);
@@ -195,6 +197,8 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
 
     @Override
     public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
+        deprecationLogger.deprecated("[javascript] scripts are deprecated, use [painless] scripts instead");
+
         Context ctx = Context.enter();
         try {
             final Scriptable scope = ctx.newObject(globalScope);

+ 5 - 1
plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java

@@ -62,7 +62,7 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
     public PythonScriptEngineService(Settings settings) {
         super(settings);
 
-        deprecationLogger.deprecated("Python scripts are deprecated.  Use Painless scripts instead.");
+        deprecationLogger.deprecated("[python] scripts are deprecated, use [painless] scripts instead.");
 
         // classloader created here
         final SecurityManager sm = System.getSecurityManager();
@@ -120,11 +120,15 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
 
     @Override
     public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> vars) {
+        deprecationLogger.deprecated("[python] scripts are deprecated, use [painless] scripts instead");
+
         return new PythonExecutableScript((PyCode) compiledScript.compiled(), vars);
     }
 
     @Override
     public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
+        deprecationLogger.deprecated("[python] scripts are deprecated, use [painless] scripts instead");
+
         return new SearchScript() {
             @Override
             public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {