Merge pull request #13958 from jpountz/remove/ScriptEngineService_unwrap

Remove ScriptEngineService.unwrap.
This commit is contained in:
Adrien Grand 2015-10-06 10:40:40 +02:00
commit ea0c35046b
12 changed files with 6 additions and 52 deletions

View File

@ -98,11 +98,6 @@ public class NativeScriptEngineService extends AbstractComponent implements Scri
return executable(compiledScript, vars).run();
}
@Override
public Object unwrap(Object value) {
return value;
}
@Override
public void close() {
}

View File

@ -44,8 +44,6 @@ public interface ScriptEngineService extends Closeable {
Object execute(CompiledScript compiledScript, Map<String, Object> vars);
Object unwrap(Object value);
/**
* Handler method called when a script is removed from the Guava cache.
*

View File

@ -138,11 +138,6 @@ public class MustacheScriptEngineService extends AbstractComponent implements Sc
throw new UnsupportedOperationException();
}
@Override
public Object unwrap(Object value) {
return value;
}
@Override
public void close() {
// Nothing to do here

View File

@ -108,11 +108,6 @@ public class MockScriptEngine implements ScriptEngineService {
return null;
}
@Override
public Object unwrap(Object value) {
return null;
}
@Override
public void scriptRemoved(@Nullable CompiledScript script) {
}

View File

@ -290,11 +290,6 @@ public class ScriptModesTests extends ESTestCase {
return null;
}
@Override
public Object unwrap(Object value) {
return null;
}
@Override
public void close() {

View File

@ -501,11 +501,6 @@ public class ScriptServiceTests extends ESTestCase {
return null;
}
@Override
public Object unwrap(Object value) {
return null;
}
@Override
public void close() {

View File

@ -242,11 +242,6 @@ public class ExpressionScriptEngineService extends AbstractComponent implements
return expressionExecutableScript.run();
}
@Override
public Object unwrap(Object value) {
return value;
}
@Override
public void close() {}

View File

@ -38,7 +38,6 @@ import org.codehaus.groovy.control.customizers.CompilationCustomizer;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.bootstrap.BootstrapInfo;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.hash.MessageDigests;
@ -259,11 +258,6 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
}
}
@Override
public Object unwrap(Object value) {
return value;
}
public static final class GroovyScript implements ExecutableScript, LeafSearchScript {
private final CompiledScript compiledScript;

View File

@ -198,11 +198,6 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
}
}
@Override
public Object unwrap(Object value) {
return ScriptValueConverter.unwrapValue(value);
}
private String generateScriptName() {
return "Script" + counter.incrementAndGet() + ".js";
}

View File

@ -97,9 +97,10 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
ctx.put("obj1", obj1);
vars.put("ctx", ctx);
se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testJavaScriptObjectMapInter", "js",
ExecutableScript executable = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testJavaScriptObjectMapInter", "js",
se.compile("ctx.obj2 = {}; ctx.obj2.prop2 = 'value2'; ctx.obj1.prop1 = 'uvalue1'")), vars);
ctx = (Map<String, Object>) se.unwrap(vars.get("ctx"));
executable.run();
ctx = (Map<String, Object>) executable.unwrap(vars.get("ctx"));
assertThat(ctx.containsKey("obj1"), equalTo(true));
assertThat((String) ((Map<String, Object>) ctx.get("obj1")).get("prop1"), equalTo("uvalue1"));
assertThat(ctx.containsKey("obj2"), equalTo(true));

View File

@ -136,11 +136,6 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
return ret.__tojava__(Object.class);
}
@Override
public Object unwrap(Object value) {
return unwrapValue(value);
}
@Override
public void close() {
interp.cleanup();

View File

@ -89,9 +89,10 @@ public class PythonScriptEngineTests extends ESTestCase {
ctx.put("obj1", obj1);
vars.put("ctx", ctx);
se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testObjectInterMap", "python",
ExecutableScript executable = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testObjectInterMap", "python",
se.compile("ctx['obj2'] = { 'prop2' : 'value2' }; ctx['obj1']['prop1'] = 'uvalue1'")), vars);
ctx = (Map<String, Object>) se.unwrap(vars.get("ctx"));
executable.run();
ctx = (Map<String, Object>) executable.unwrap(vars.get("ctx"));
assertThat(ctx.containsKey("obj1"), equalTo(true));
assertThat((String) ((Map<String, Object>) ctx.get("obj1")).get("prop1"), equalTo("uvalue1"));
assertThat(ctx.containsKey("obj2"), equalTo(true));