This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.js.provider-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
commit 5b7f8f094b2ed291b938f9090c12c79e2c94423d Author: Radu Cotescu <[email protected]> AuthorDate: Wed Mar 18 16:41:15 2015 +0000 SLING-4515 - Insufficient cleanup of the JavaScript execution engine leads to runtime errors * made sure to always call JsEnvironment#cleanup before finishing execution for JsUseProvider#provide git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/sightly/js-use-provider@1667586 13f79535-47bb-0310-9956-ffa450edef68 --- .../scripting/sightly/js/impl/JsUseProvider.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java index 35cc70d..ac2c886 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java +++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java @@ -90,12 +90,19 @@ public class JsUseProvider implements UseProvider { return ProviderOutcome.failure(new SightlyException("No JavaScript engine was defined.")); } SlingScriptHelper scriptHelper = Utils.getHelper(globalBindings); - JsEnvironment environment = new JsEnvironment(jsEngine); - environment.initialize(); - String callerPath = scriptHelper.getScript().getScriptResource().getPath(); - ResourceResolver adminResolver = renderContext.getScriptResourceResolver(); - Resource caller = adminResolver.getResource(callerPath); - AsyncContainer asyncContainer = environment.run(caller, identifier, globalBindings, arguments); - return ProviderOutcome.success(jsValueAdapter.adapt(asyncContainer)); + JsEnvironment environment = null; + try { + environment = new JsEnvironment(jsEngine); + environment.initialize(); + String callerPath = scriptHelper.getScript().getScriptResource().getPath(); + ResourceResolver adminResolver = renderContext.getScriptResourceResolver(); + Resource caller = adminResolver.getResource(callerPath); + AsyncContainer asyncContainer = environment.run(caller, identifier, globalBindings, arguments); + return ProviderOutcome.success(jsValueAdapter.adapt(asyncContainer)); + } finally { + if (environment != null) { + environment.cleanup(); + } + } } } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
