NPE in SlingIOProvider if resource does not exist
-------------------------------------------------

                 Key: SLING-158
                 URL: https://issues.apache.org/jira/browse/SLING-158
             Project: Sling
          Issue Type: Bug
          Components: JSP
            Reporter: Tobias Bocanegra


for example when resolving a tag library:

Caused by: java.lang.NullPointerException
        at 
org.apache.sling.scripting.jsp.SlingIOProvider.getInputStream(SlingIOProvider.java:96)
        at 
org.apache.sling.scripting.jsp.jasper.compiler.TagLibraryInfoImpl.getResourceAsStream(TagLibraryInfoImpl.java:120)
        at 
org.apache.sling.scripting.jsp.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:155)
        at 
org.apache.sling.scripting.jsp.jasper.compiler.Parser.parseTaglibDirective(Parser.java:420)
        at 
org.apache.sling.scripting.jsp.jasper.compiler.Parser.parseDirective(Parser.java:476)
        at 
org.apache.sling.scripting.jsp.jasper.compiler.Parser.parseElements(Parser.java:1426)
        at 
org.apache.sling.scripting.jsp.jasper.compiler.Parser.parse(Parser.java:133)

Suggested patch:

Index: src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
===================================================================
--- src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java   
(revision 612138)
+++ src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java   
(working copy)
@@ -93,6 +93,9 @@
             throws FileNotFoundException, IOException {
         try {
             Resource resource = getResourceInternal(fileName);
+            if (resource == null) {
+                throw new FileNotFoundException("Cannot find " + fileName);
+            }
             InputStream stream = resource.adaptTo(InputStream.class);
             if (stream == null) {
                 throw new FileNotFoundException("Cannot find " + fileName);


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to