Hi all,
Sorry about the very short reply from my phone. To clarify, I’ve started playing with Servlets again recently to refresh my memory. In particular I wanted to see why a certain “enterprise” system that’s written in Java had a hard time handle more than 30 concurrent file uploads per second on a relatively high specced hardware.
The JavaDoc for javax.servlet.ServletRequest#getInputStream()
reads:
@exception IllegalStateException if the {@link #getReader} method has already been called for this request
Similarly the JavaDoc for javax.servlet.ServletRequest#getReader()
reads:
@exception IllegalStateException if {@link #getInputStream} method has been called on this request
So, IMHO, if we call getInputStream
/getReader
after calling javax.servlet.http.HttpServletRequest#getParts
/javax.servlet.http.HttpServletRequest#getPart
, they should throw IllegalStateException
, instead of returning an empty stream.
If for backwards compatibility it is too late to enforce that, then the spec can be updated and mention that it is up to the implementor what to do in this scenario.