Hello all,

Referencing a Servlet input stream - by calling ServletRequest.getInputStream(), which 
propagates down to CoyoteRequest.getInputStream() - in Tomcat 4/5 stops POST'ed body parameters 
from being parsed. See "usingInputStream" instance member declared at 
CoyoteRequest:200 and referenced/modified at CoyoteRequest:824 and CoyoteRequest:1922 (in the 
nightly snapshot 20040726).

I have not raised this as a bug as the Servlet Spec. and JavaDocs leaves a window open 
for interpretation. Java doc for method ServletRequest.getParameter(String) says:

[...]
If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method. [...]


And the Servlet 2.3 Spec. SRV 4.1.1 also fails to nail it down.

However, the current implementation in Tomcat 4/5 has serious and in circumstances 
hard-to-find side effects. (And conflicts with Tomcat 3, Caucho's Resin, Jetty and so 
on).

In our case, a complex application runtime needed to hide Servlet details behind an 
abstraction layer and thus referencing the input stream ahead of use without knowing 
if any subsystem would later require it. This referencing was done before getting any 
parameters, with the side effect that POST'ed parameters disappeared. And what 
resulted was a very non-trivial bug. It became even harder when the addition of a 
request dumper valve when debugging had the apparent side effect of solving the 
problem (as then the parameters are referenced before the input stream) thus 
indicating that this was a Tomcat bug and not an application bug, as you do not expect 
a component added outside the Servlet web application to have such a side effect. All 
in all, approx. 6 hours of debugging followed.

Perhaps the setting of the CoyoteRequest.usingInpuStream member should be delayed until actual reading of the stream and not only referencing.

If you'd rather have me post this directly as a bug, I'd of course be happy to.

Regards
- Lars J. Nilsson

================
Senior Developer
RecipeXperience Ltd.











---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to