Bug 54220 - ErrorReportValve invoked on non-error responses too
ErrorReportValve invoked on non-error responses too
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
6.0.36
All All
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-11-28 20:19 UTC by Michael Osipov
Modified: 2012-12-06 14:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2012-11-28 20:19:49 UTC
If you issue a response.setStatus(404) from a servlet, you expect as per spec that the response is left untouched. No error page written. There is sendError for that.

Unfortunately, ErrorReportValve reacts on line 158
> if ((statusCode < 400) || (response.getContentCount() > 0))
>            return;

If you take a look at the StandardHostValve, it invokes error handling on line 316
> if (!response.isError())
>            return;
On errors only (correct behavior).

The ErrorReportValve must react on response.isError() == true only. Regardless of the status code or the content count.
The Javadoc does not limit this to status codes >= 400 but is says that reponse.sendError() has to clears buffers. As far I understand that, regardless of the response body is disposed and the error reponse is always written.
Comment 1 Mark Thomas 2012-12-03 14:21:22 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.34 onwards.
Comment 2 Mark Thomas 2012-12-03 14:23:56 UTC
Opps. Need to keep this open until 6.0x. is fixed.
Comment 3 Mark Thomas 2012-12-03 14:42:38 UTC
Proposed for 6.0.x
Comment 4 Konstantin Kolinko 2012-12-06 14:56:19 UTC
Fixed in Tomcat 6 by r1417925 , will be in 6.0.37 onwards.