sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r648189 - /incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScript.java
Date Tue, 15 Apr 2008 09:12:48 GMT
Author: fmeschbe
Date: Tue Apr 15 02:12:47 2008
New Revision: 648189

URL: http://svn.apache.org/viewvc?rev=648189&view=rev
Log:
SLING-380 Ensure script reader is closed after evaluating the script

Modified:
    incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScript.java

Modified: incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScript.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScript.java?rev=648189&r1=648188&r2=648189&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScript.java
(original)
+++ incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScript.java
Tue Apr 15 02:12:47 2008
@@ -116,6 +116,7 @@
         final String scriptName = getScriptResource().getPath();
 
         Bindings bindings = null;
+        Reader reader = null;
         try {
             bindings = verifySlingBindings(scriptName, props);
 
@@ -125,7 +126,7 @@
             ctx.setWriter((Writer) bindings.get(OUT));
             ctx.setErrorWriter(new LogWriter((Logger) bindings.get(LOG)));
 
-            Reader reader = getScriptReader();
+            reader = getScriptReader();
             if ( method != null && !(this.scriptEngine instanceof Invocable)) {
                 reader = getWrapperReader(reader, method, args);
             }
@@ -151,6 +152,7 @@
             ctx.getErrorWriter().flush();
 
             return result;
+            
         } catch (IOException ioe) {
             throw new ScriptEvaluationException(scriptName, ioe.getMessage(),
                 ioe);
@@ -159,11 +161,22 @@
             Throwable cause = (se.getCause() == null) ? se : se.getCause();
             throw new ScriptEvaluationException(scriptName, se.getMessage(),
                 cause);
+            
         } finally {
+            // dispose of the SlingScriptHelper
             if ( bindings != null ) {
                 final SlingScriptHelper helper = (SlingScriptHelper) bindings.get(SLING);
                 if ( helper != null ) {
                     helper.dispose();
+                }
+            }
+            
+            // close the script reader (SLING-380)
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException ignore) {
+                    // don't care
                 }
             }
         }



Mime
View raw message