incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r918350 - /sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
Date Wed, 03 Mar 2010 07:40:17 GMT
Author: cziegeler
Date: Wed Mar  3 07:40:17 2010
New Revision: 918350

URL: http://svn.apache.org/viewvc?rev=918350&view=rev
Log:
SLING-1422 : NPE when a script is called without a request binding

Modified:
    sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java

Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java?rev=918350&r1=918349&r2=918350&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
(original)
+++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
Wed Mar  3 07:40:17 2010
@@ -134,6 +134,9 @@
 
     // ---------- SlingScript interface ----------------------------------------
 
+    /**
+     * @see org.apache.sling.api.scripting.SlingScript#getScriptResource()
+     */
     public Resource getScriptResource() {
         final ResourceResolver resolver = requestResourceResolver.get();
         if ( resolver == null ) {
@@ -202,8 +205,10 @@
             ctx.setWriter((Writer) bindings.get(OUT));
             ctx.setErrorWriter(new LogWriter((Logger) bindings.get(LOG)));
 
-            // set the current resource resolver
-            requestResourceResolver.set(props.getRequest().getResourceResolver());
+            // set the current resource resolver if a request is available from the bindings
+            if ( props.getRequest() != null ) {
+                requestResourceResolver.set(props.getRequest().getResourceResolver());
+            }
 
             // set the script resource resolver as an attribute
             ctx.setAttribute(SlingScriptConstants.ATTR_SCRIPT_RESOURCE_RESOLVER,
@@ -451,9 +456,9 @@
         };
     }
 
-    private Bindings verifySlingBindings(SlingBindings slingBindings) throws IOException
{
+    private Bindings verifySlingBindings(final SlingBindings slingBindings) throws IOException
{
 
-    	Bindings bindings = new SimpleBindings();
+    	final Bindings bindings = new SimpleBindings();
 
         final SlingHttpServletRequest request = slingBindings.getRequest();
 
@@ -473,9 +478,7 @@
         bindings.put(SLING, sling);
 
         if (request != null) {
-            //throw fail(REQUEST, "Missing or wrong type");
-
-        	SlingHttpServletResponse response = slingBindings.getResponse();
+        	final SlingHttpServletResponse response = slingBindings.getResponse();
             if (response == null) {
                 throw fail(RESPONSE, "Missing or wrong type");
             }



Mime
View raw message