tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 52577] New: Response output written in filter can be truncated
Date Thu, 02 Feb 2012 07:45:44 GMT

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

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

if (gotEnc && conv != null) {

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

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

Maybe you should change flushing to something like that:

if (conv != null) {

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

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message