sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1667586 - /sling/trunk/contrib/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
Date Wed, 18 Mar 2015 16:41:15 GMT
Author: radu
Date: Wed Mar 18 16:41:15 2015
New Revision: 1667586

URL: http://svn.apache.org/r1667586
Log:
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

Modified:
    sling/trunk/contrib/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java

Modified: sling/trunk/contrib/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java?rev=1667586&r1=1667585&r2=1667586&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
(original)
+++ sling/trunk/contrib/scripting/sightly/js-use-provider/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
Wed Mar 18 16:41:15 2015
@@ -90,12 +90,19 @@ public class JsUseProvider implements Us
             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();
+            }
+        }
     }
 }



Mime
View raw message