tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52577] New: Response output written in filter can be truncated
Date Thu, 02 Feb 2012 07:45:44 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52577

             Bug #: 52577
           Summary: Response output written in filter can be truncated
           Product: Tomcat 7
           Version: 7.0.25
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: dmitry.neverov@gmail.com
    Classification: Unclassified


Due to changes 1229726, 1229727 and 1229728 output written to response in the
filter can be truncated up to 8192 bytes. Consider the following scenario:

- you have a filter that invoke getWriter() before chain.doFilter(request,
responseWrapper)


- responseWrapper overrides getWriter() method and returns some
  buffered writer, not the real one


- during execution of chain.doFilter there is a forward


Before the forward ApplicationDispather calls resetBuffer on response, which in
turn calls reset() on OutputBuffer, which sets gotEnc field to false. This
field is initialized in the setConverter() method which is called from
response.getWriter(), but since our wrapperResponse overrides getWriter(),
OutputBuffer.setConverter() never called and OutputBuffer still has gotEnc =
false.


Response's close() and flushBuffer() methods call OutputBuffer's flush(), but
since gotEnc == false, conv.flushBuffer() is not called:


if (gotEnc && conv != null) {
    conv.flushBuffer();
}


A workaround for us is to implement getWriter() method in responseWrapper like
this:


public Writer getWriter() {
  Writer originalWriter = originalResponse.getWriter();//save for future
processing
  return ourWriter;
}


Maybe you should change flushing to something like that:


if (conv != null) {
    conv.flushBuffer();
}


because you invoke conv.convert() without any checks in the write*() methods
and it seems like conv is never null.

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


Mime
View raw message