diff --git a/docs/plugins/lang-javascript.asciidoc b/docs/plugins/lang-javascript.asciidoc index 48cf9763500..4bc6ba94ed2 100644 --- a/docs/plugins/lang-javascript.asciidoc +++ b/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 <>] +deprecated[5.0.0,JavaScript will be replaced by the new scripting language <>] The JavaScript language plugin enables the use of JavaScript in Elasticsearch scripts, via Mozilla's diff --git a/docs/reference/modules/scripting/using.asciidoc b/docs/reference/modules/scripting/using.asciidoc index 5f925bc7058..17ab4a8180a 100644 --- a/docs/reference/modules/scripting/using.asciidoc +++ b/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: diff --git a/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java b/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java index 923219d908a..7b82059fa2a 100644 --- a/modules/lang-groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java +++ b/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 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 vars) { + deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead"); + try { Map 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 vars) { + deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead"); + return new SearchScript() { @Override diff --git a/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java b/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java index d418e9877c7..da3d14cd02b 100644 --- a/plugins/lang-javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java +++ b/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 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 vars) { + deprecationLogger.deprecated("[javascript] scripts are deprecated, use [painless] scripts instead"); + Context ctx = Context.enter(); try { final Scriptable scope = ctx.newObject(globalScope); diff --git a/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java b/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java index 69ff2ffe70f..d31e691b994 100644 --- a/plugins/lang-python/src/main/java/org/elasticsearch/script/python/PythonScriptEngineService.java +++ b/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 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 vars) { + deprecationLogger.deprecated("[python] scripts are deprecated, use [painless] scripts instead"); + return new SearchScript() { @Override public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {