From 25f6edd0651e13ded919edf4101fb14b1c9d21e8 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 8 Feb 2016 22:40:05 +0000 Subject: [PATCH] Use shared Groovy script engine --- source/net/filebot/format/ExpressionFileFilter.java | 8 ++++---- source/net/filebot/format/ExpressionFilter.java | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/source/net/filebot/format/ExpressionFileFilter.java b/source/net/filebot/format/ExpressionFileFilter.java index dd69d6c6..4fcfa60f 100644 --- a/source/net/filebot/format/ExpressionFileFilter.java +++ b/source/net/filebot/format/ExpressionFileFilter.java @@ -10,11 +10,11 @@ import java.util.logging.Logger; public class ExpressionFileFilter implements FileFilter { private final ExpressionFilter filter; - private final boolean errorResult; + private final boolean error; - public ExpressionFileFilter(ExpressionFilter filter, boolean errorResult) { + public ExpressionFileFilter(ExpressionFilter filter, boolean error) { this.filter = filter; - this.errorResult = errorResult; + this.error = error; } public ExpressionFilter getExpressionFilter() { @@ -27,7 +27,7 @@ public class ExpressionFileFilter implements FileFilter { return filter.matches(new MediaBindingBean(readMetaInfo(f), f, null)); } catch (Exception e) { Logger.getLogger(ExpressionFileFilter.class.getName()).log(Level.WARNING, e.toString()); - return errorResult; + return error; } } diff --git a/source/net/filebot/format/ExpressionFilter.java b/source/net/filebot/format/ExpressionFilter.java index bcfee0a5..4e34ad41 100644 --- a/source/net/filebot/format/ExpressionFilter.java +++ b/source/net/filebot/format/ExpressionFilter.java @@ -1,9 +1,10 @@ package net.filebot.format; +import static net.filebot.format.ExpressionFormat.*; + import java.security.AccessController; import javax.script.Bindings; -import javax.script.Compilable; import javax.script.CompiledScript; import javax.script.ScriptContext; import javax.script.ScriptException; @@ -20,9 +21,7 @@ public class ExpressionFilter { public ExpressionFilter(String expression) throws ScriptException { this.expression = expression; - - Compilable engine = (Compilable) ExpressionFormat.getGroovyScriptEngine(); - this.compiledExpression = new SecureCompiledScript(engine.compile(expression)); // sandboxed script + this.compiledExpression = new SecureCompiledScript(compileScriptlet(expression)); } public String getExpression() {