FAQ

[Tomcat-dev] Bug 42409

Tim Funk
Oct 23, 2008 at 11:07 am
1) I think you might also need in StandardHostValve.java:
setStatus(status, message);
But the more I dig the less I am convinced that the above snippet is needed.

2) And then this probably needs deprecated
public void reset(int status, String message) {

3) reset() also did this:
coyoteResponse.reset();
outputBuffer.reset();
usingOutputStream = false;
usingWriter = false;
isCharacterEncodingSet = false;
And the patch eventually just does this: outputBuffer.reset() so by the
change - will Errors get thrown if a Writer is requested by the error
processing when a OutputStream was already allocated? Likewise - would
char encoding be set/reset correctly?

-Tim


Filip Hanik - Dev Lists wrote:
Looking through the bug

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

I do believe that the author might correct in his assumption.
When we do a forward, in ApplicationDispatcher we call

try {
response.resetBuffer();
} catch (IllegalStateException e) {
throw e;
}

according to the specification,

however, when the webapp calls 'sendError' we do a
response.reset(code,msg), which clears all the headers.

the JavaDoc for sendError say
-------------------------
sendError(int)
public void sendError(int sc)
throws IOException
Sends an error response to the client using the specified status code
and clearing
the buffer.
If the response has already been committed, this method throws an Illegal-
StateException. After using this method, the response should be considered
to be committed and should not be written to.
-------------------------


I believe the fix that is being suggest is correct,

any takers?

Index: java/org/apache/catalina/core/StandardHostValve.java
===================================================================
--- java/org/apache/catalina/core/StandardHostValve.java
(revision 706079)
+++ java/org/apache/catalina/core/StandardHostValve.java (working
copy)
@@ -414,7 +414,7 @@
int statusCode = statusCodeObj.intValue();
String message =
(String) request.getAttribute(Globals.ERROR_MESSAGE_ATTR);
- response.reset(statusCode, message);
+ response.resetBuffer();

// Forward control to the specified location
ServletContext servletContext =

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

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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›