You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2018/08/28 06:40:22 UTC
[sling-org-apache-sling-scripting-sightly] branch master updated:
SLING-7859 - The HTL engine sets the script bindings two times
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly.git
The following commit(s) were added to refs/heads/master by this push:
new 4d605e8 SLING-7859 - The HTL engine sets the script bindings two times
4d605e8 is described below
commit 4d605e851796e53a503b9a8ba220f9577470c847
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Aug 28 08:40:13 2018 +0200
SLING-7859 - The HTL engine sets the script bindings two times
* removed redundant code
---
.../sightly/impl/engine/SightlyScriptEngine.java | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/SightlyScriptEngine.java b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/SightlyScriptEngine.java
index 8bf8ac1..4d08e8c 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/SightlyScriptEngine.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/SightlyScriptEngine.java
@@ -21,6 +21,7 @@ package org.apache.sling.scripting.sightly.impl.engine;
import java.io.Reader;
import java.io.StringReader;
import java.util.Set;
+
import javax.script.Bindings;
import javax.script.Compilable;
import javax.script.CompiledScript;
@@ -29,9 +30,6 @@ import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptException;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.api.scripting.SlingScriptHelper;
import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
import org.apache.sling.scripting.api.ScriptNameAware;
@@ -92,22 +90,11 @@ public class SightlyScriptEngine extends AbstractSlingScriptEngine implements Co
@Override
public Object eval(Reader reader, ScriptContext scriptContext) throws ScriptException {
checkArguments(reader, scriptContext);
- Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
- SlingBindings slingBindings = new SlingBindings();
- slingBindings.putAll(bindings);
- final SlingHttpServletRequest request = slingBindings.getRequest();
- if (request == null) {
- throw new SightlyException("Missing SlingHttpServletRequest from ScriptContext.");
- }
- final Object oldValue = request.getAttribute(SlingBindings.class.getName());
try {
- request.setAttribute(SlingBindings.class.getName(), slingBindings);
SightlyCompiledScript compiledScript = internalCompile(reader, scriptContext);
return compiledScript.eval(scriptContext);
} catch (Exception e) {
throw new ScriptException(e);
- } finally {
- request.setAttribute(SlingBindings.class.getName(), oldValue);
}
}