diff --git a/core/src/main/java/org/elasticsearch/script/ScriptEngine.java b/core/src/main/java/org/elasticsearch/script/ScriptEngine.java index 9572e891b3c..2256ecbb264 100644 --- a/core/src/main/java/org/elasticsearch/script/ScriptEngine.java +++ b/core/src/main/java/org/elasticsearch/script/ScriptEngine.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.search.lookup.SearchLookup; import java.io.Closeable; +import java.io.IOException; import java.util.Map; /** @@ -47,4 +48,7 @@ public interface ScriptEngine extends Closeable { ExecutableScript executable(CompiledScript compiledScript, @Nullable Map vars); SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map vars); + + @Override + default void close() throws IOException {} } diff --git a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java index edc224da0db..cdd939cf607 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java @@ -69,7 +69,6 @@ public class ScriptServiceTests extends ESTestCase { } scripts.put("script", p -> null); scriptEngine = new MockScriptEngine(Script.DEFAULT_SCRIPT_LANG, scripts); - //prevent duplicates using map contexts = new HashMap<>(ScriptContext.BUILTINS); engines = new HashMap<>(); @@ -316,5 +315,4 @@ public class ScriptServiceTests extends ESTestCase { notNullValue() ); } - } diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java index 40418048e5a..8711e9ef3da 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java @@ -101,9 +101,6 @@ public class ExplainableScriptIT extends ESIntegTestCase { } }; } - - @Override - public void close() {} }; } } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java index b08eaee3daf..b11d6ce07a5 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestSearchIT.java @@ -1021,10 +1021,6 @@ public class SuggestSearchIT extends ESIntegTestCase { // which makes the collate code thinks mustache is evaluating the query. public static final String NAME = "mustache"; - @Override - public void close() throws IOException { - } - @Override public String getType() { return NAME; diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java index 11a10247e03..73d1af32c0c 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java @@ -252,7 +252,4 @@ public class ExpressionScriptEngine extends AbstractComponent implements ScriptE public ExecutableScript executable(CompiledScript compiledScript, Map vars) { return new ExpressionExecutableScript(compiledScript, vars); } - - @Override - public void close() {} } diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java index d5e35b6383f..28ba360025a 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java @@ -97,11 +97,6 @@ public final class MustacheScriptEngine implements ScriptEngine { throw new UnsupportedOperationException(); } - @Override - public void close() { - // Nothing to do here - } - /** * Used at query execution time by script service in order to execute a query template. * */ diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessScriptEngine.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessScriptEngine.java index d362229c218..aa30302f2ae 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessScriptEngine.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessScriptEngine.java @@ -211,14 +211,6 @@ public final class PainlessScriptEngine extends AbstractComponent implements Scr }; } - /** - * Action taken when the engine is closed. - */ - @Override - public void close() { - // Nothing to do. - } - private ScriptException convertToScriptException(String scriptName, String scriptSource, Throwable t) { // create a script stack: this is just the script portion List scriptStack = new ArrayList<>(); diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/NeedsScoreTests.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/NeedsScoreTests.java index 4611893b645..1c729053d7b 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/NeedsScoreTests.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/NeedsScoreTests.java @@ -60,7 +60,6 @@ public class NeedsScoreTests extends ESSingleNodeTestCase { ss = service.search(new CompiledScript(ScriptType.INLINE, "randomName", "painless", compiled), lookup, Collections.emptyMap()); assertTrue(ss.needsScores()); - service.close(); } } diff --git a/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java b/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java index b06743b95e7..8a13b2fed7d 100644 --- a/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java +++ b/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java @@ -134,7 +134,9 @@ public class ExpertScriptPlugin extends Plugin implements ScriptPlugin { } @Override - public void close() {} + public void close() { + // optionally close resources + } } // end::expert_engine } diff --git a/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java b/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java index c34a858791b..d685a9f9518 100644 --- a/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java +++ b/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java @@ -90,10 +90,6 @@ public class MockScriptEngine implements ScriptEngine { return compiled.createSearchScript(vars, lookup); } - @Override - public void close() throws IOException { - } - public class MockCompiledScript { private final String name;