Bug 58578 - NullPointerException in Request.parseCookies().
NullPointerException in Request.parseCookies().
Status: RESOLVED FIXED
Product: Tomcat 8
Classification: Unclassified
Component: Catalina
8.0.21
PC Linux
: P2 normal (vote)
: ----
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2015-11-03 17:33 UTC by Corey Puffalt
Modified: 2015-11-03 18:01 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Corey Puffalt 2015-11-03 17:33:49 UTC
I've run into a NullPointerException when the AccessLogValve is configured to log a cookie:

02-Nov-2015 18:19:45.461 SEVERE [ajp-nio-8009-exec-1] org.apache.coyote.ajp.AbstractAjpProcessor.process Error processing request
 java.lang.NullPointerException
        at org.apache.catalina.connector.Request.parseCookies(Request.java:2948)
        at org.apache.catalina.connector.Request.convertCookies(Request.java:2963)
        at org.apache.catalina.connector.Request.getCookies(Request.java:1992)
        at org.apache.catalina.valves.AbstractAccessLogValve$CookieElement.addElement(AbstractAccessLogValve.java:1335)
        at org.apache.catalina.valves.AbstractAccessLogValve.log(AbstractAccessLogValve.java:639)
        at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)
        at org.apache.catalina.core.ContainerBase.logAccess(ContainerBase.java:1043)
        at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:893)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:513)
        at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:844)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

02-Nov-2015 18:19:45.464 WARNING [ajp-nio-8009-exec-1] org.apache.catalina.connector.CoyoteAdapter.log Exception while attempting to add an entry to the access log
 java.lang.NullPointerException
        at org.apache.catalina.connector.Request.parseCookies(Request.java:2948)
        at org.apache.catalina.connector.Request.convertCookies(Request.java:2963)
        at org.apache.catalina.connector.Request.getCookies(Request.java:1992)
        at org.apache.catalina.valves.AbstractAccessLogValve$CookieElement.addElement(AbstractAccessLogValve.java:1335)
        at org.apache.catalina.valves.AbstractAccessLogValve.log(AbstractAccessLogValve.java:639)
        at org.apache.catalina.core.AccessLogAdapter.log(AccessLogAdapter.java:51)
        at org.apache.catalina.core.StandardEngine.logAccess(StandardEngine.java:342)
        at org.apache.catalina.connector.CoyoteAdapter.log(CoyoteAdapter.java:675)
        at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:853)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

Here's the valve configuration:

        <Valve className="org.apache.catalina.valves.AccessLogValve"
          directory="logs" prefix="access.log." suffix=""
          pattern="%h %l %u %t &quot;%r&quot; %s %b &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot; %{JSESSIONID}c %D %I"/>

RedHat has posted an article with the same exception noted: https://access.redhat.com/solutions/1992003.  Unfortunately, the information is hidden behind a paywall I don't have access to.  However I searched Bugzilla and can find no evidence that they submitted a ticket upstream.

Thanks.
Comment 1 Remy Maucherat 2015-11-03 18:01:37 UTC
From what I see the context is null, so this means this is about requests that have not been mapped but are access logged anyway.

This should be fixed in r1712358 that will be in Tomcat 8.0.29. Tomcat 7 is likely not affected.

The cookie processor is associated with contexts in Tomcat 8+, so cookie processing will not occur for unmapped requests and they will appear as if they had no cookies. If this is somehow important (I do not think so at the moment), then another "generic" cookie processor will have to exist for these kind of situations.