Calling the SlingMainServlet during startup may cause NullPointerException
--------------------------------------------------------------------------

                 Key: SLING-1766
                 URL: https://issues.apache.org/jira/browse/SLING-1766
             Project: Sling
          Issue Type: Bug
          Components: Engine
    Affects Versions: Engine 2.1.0
            Reporter: Felix Meschberger
            Assignee: Felix Meschberger
             Fix For: Engine 2.1.2


If during startup the Sling Main Servlet is called, a NullPointerException 
might be thrown as follows:


10.09.2010 21:25:37.936 *ERROR* [127.0.0.1 [1284146737935] GET /login.html 
HTTP/1.1] org.apache.sling.engine.impl.SlingMainServlet service: Uncaught 
Problem handling the request java.lang.NullPointerException
    at 
org.apache.sling.engine.impl.SlingHttpServletResponseImpl.flushBuffer(SlingHttpServletResponseImpl.java:131)
    at 
org.apache.sling.engine.impl.DefaultErrorHandler.sendError(DefaultErrorHandler.java:161)
    at 
org.apache.sling.engine.impl.DefaultErrorHandler.handleError(DefaultErrorHandler.java:79)
    at 
org.apache.sling.engine.impl.SlingRequestProcessorImpl.handleError(SlingRequestProcessorImpl.java:318)
    at 
org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:200)
    at 
org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:174)
    ...

The reason for this problem is, that the 
SlingRequestProcessorImpl.processRequest checks for the presence of services 
required for request processing. If these services are not available, an 
exception is thrown which is handled in the catch clause. This catch clause 
uses the Sling request and response object to send the response using the Sling 
error handling infrastructure. Unfortunately these objects have not been fully 
prepared at this time and thus a precondition for sending response data is 
missing in the Sling response.

The fix is to use the servlet container error handling infrastructure instead.

-- 
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