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

This commit is contained in:
Jack Conradson 2016-08-31 15:56:31 -07:00
parent 3077060147
commit 3b3baa6e6c
5 changed files with 18 additions and 13 deletions

View File

@ -1,7 +1,7 @@
[[lang-javascript]] [[lang-javascript]]
=== JavaScript Language Plugin === 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 The JavaScript language plugin enables the use of JavaScript in Elasticsearch
scripts, via Mozilla's scripts, via Mozilla's

View File

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

View File

@ -92,13 +92,11 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
*/ */
private final ClassLoader loader; 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) { public GroovyScriptEngineService(Settings settings) {
super(settings); super(settings);
deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead");
// Creates the classloader here in order to isolate Groovy-land code // Creates the classloader here in order to isolate Groovy-land code
final SecurityManager sm = System.getSecurityManager(); final SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
@ -140,10 +138,6 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
@Override @Override
public Object compile(String scriptName, String scriptSource, Map<String, String> params) { 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 // Create the script class name
String className = MessageDigests.toHexString(MessageDigests.sha1().digest(scriptSource.getBytes(StandardCharsets.UTF_8))); String className = MessageDigests.toHexString(MessageDigests.sha1().digest(scriptSource.getBytes(StandardCharsets.UTF_8)));
@ -189,6 +183,8 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
@Override @Override
public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> vars) { public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> vars) {
deprecationLogger.deprecated("[groovy] scripts are deprecated, use [painless] scripts instead");
try { try {
Map<String, Object> allVars = new HashMap<>(); Map<String, Object> allVars = new HashMap<>();
if (vars != null) { if (vars != null) {
@ -202,6 +198,8 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
@Override @Override
public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) { 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() { return new SearchScript() {
@Override @Override

View File

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

View File

@ -62,7 +62,7 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
public PythonScriptEngineService(Settings settings) { public PythonScriptEngineService(Settings settings) {
super(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 // classloader created here
final SecurityManager sm = System.getSecurityManager(); final SecurityManager sm = System.getSecurityManager();
@ -120,11 +120,15 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
@Override @Override
public ExecutableScript executable(CompiledScript compiledScript, Map<String, Object> vars) { 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); return new PythonExecutableScript((PyCode) compiledScript.compiled(), vars);
} }
@Override @Override
public SearchScript search(final CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) { 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() { return new SearchScript() {
@Override @Override
public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException { public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {