You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2008/12/09 19:04:17 UTC

DO NOT REPLY [Bug 46370] New: NullPointerException in AccessLogValve

https://issues.apache.org/bugzilla/show_bug.cgi?id=46370

           Summary: NullPointerException in AccessLogValve
           Product: Tomcat 6
           Version: 6.0.18
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: ishi.spam@gmail.com


I get a NullPointerException (stacktrace follows) when I call
getNext().invoke(...) in my Valve, when in the valve chain exists the
AccessLogValve.

My valve creates a 'wrapper' for the Response using a class like this:

public class CountingResponse extends ResponseDecorator {
        final private transient AtomicInteger counter;
        private CountingResponseWrapper wrapper;

        public CountingResponse(final Response target) {
                super(target);
                wrapper = null;
                counter = new AtomicInteger(0);
        }

        @Override
        public synchronized HttpServletResponse getResponse() {
                if (wrapper == null) {
                        final HttpServletResponse supResponse =
super.getResponse();
                        if (supResponse == null) {
                                return null;
                        }
                        wrapper = new CountingResponseWrapper(supResponse,
counter);
                }
                return wrapper;
        }

        @Override
        public ServletOutputStream getOutputStream() throws IOException {
                final ServletOutputStream stream = super.getOutputStream();
                if (stream instanceof CountingOutputStream) {
                        return stream;
                }
                return new CountingOutputStream(stream, counter);
        }

        @Override
        public PrintWriter getWriter() throws IOException {
                final PrintWriter writer = super.getWriter();
                if (writer instanceof CountingWriter) {
                        return writer;
                }
                return new CountingWriter(writer, counter);
        }

        public int getCounter() {
                return counter.get();
        }
}

The ResponseDecorator is a a class that extends
org.apache.catalina.connector.Response, its constructor takes Response (target)
as argument and all public and protected calls are redirected to target (a
simple decorator).

The stacktrace:

java.lang.NullPointerException
        at
org.apache.catalina.connector.Response.getContentCountLong(Response.java:313)
        at
org.apache.catalina.valves.AccessLogValve$ByteSentElement.addElement(AccessLogValve.java:1102)
        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:582)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:209)
        at
org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:347)
        at pl.avantis.tomcat.valves.RemoteCLValve.invoke(RemoteCLValve.java:77)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46370] NullPointerException in AccessLogValve

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46370


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Mark Thomas <ma...@apache.org>  2008-12-26 15:33:11 PST ---
Looks like a problem with your wrapper. The line of the NPE indicates that the
outputBuffer is null. The users list is the place to get help with this in the
first instance.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org