INT-3970: Fix ScriptExecutor for Wrong lang

JIRA: https://jira.spring.io/browse/INT-3970

NOTE: Don't see reason to back-port, because we have catched `ScriptingException` for the same reason at runtime.

Fix typo in the `AbstractScriptExecutor` method name.

Use that method from the `Assert`on the `engine`
This commit is contained in:
Artem Bilan
2016-03-22 12:46:37 -04:00
committed by Gary Russell
parent 66cd92a6e7
commit 956cf275e1
3 changed files with 26 additions and 33 deletions

View File

@@ -53,16 +53,10 @@ public abstract class AbstractScriptExecutor implements ScriptExecutor {
Assert.hasText(language, "language must not be empty");
this.language = language;
scriptEngine = new ScriptEngineManager().getEngineByName(this.language);
this.scriptEngine = new ScriptEngineManager().getEngineByName(this.language);
Assert.notNull(this.scriptEngine, invalidLanguageMessage(this.language));
if (logger.isDebugEnabled()) {
if (scriptEngine == null) {
logger.error(invlalidLanguageMessage(this.language));
}
else {
logger.debug("using script engine : " + scriptEngine.getFactory().getEngineName());
}
logger.debug("Using script engine : " + scriptEngine.getFactory().getEngineName());
}
}
@@ -73,7 +67,7 @@ public abstract class AbstractScriptExecutor implements ScriptExecutor {
@Override
public Object executeScript(ScriptSource scriptSource, Map<String, Object> variables) {
Object result = null;
Object result;
try {
String script = scriptSource.getScriptAsString();
@@ -115,10 +109,10 @@ public abstract class AbstractScriptExecutor implements ScriptExecutor {
*/
protected abstract Object postProcess(Object result, ScriptEngine scriptEngine, String script, Bindings bindings);
private static String invlalidLanguageMessage(String language) {
return new StringBuilder().append(ScriptEngineManager.class.getName())
.append(" is unable to create a script engine for language '").append(language).append("'.\n")
.append("This may be due to a missing language implementation or an invalid language name.").toString();
private static String invalidLanguageMessage(String language) {
return ScriptEngineManager.class.getName() +
" is unable to create a script engine for language '" + language + "'.\n" +
"This may be due to a missing language implementation or an invalid language name.";
}
}

View File

@@ -34,7 +34,7 @@ import org.springframework.integration.scripting.ScriptExecutor;
* Create a DefaultScriptExecutor for the specified language name (JSR233
* alias).
*/
DefaultScriptExecutor(String language) {
public DefaultScriptExecutor(String language) {
super(language);
}