I've recently been involved in a project, that had some problems with
HTTP posts from some clients. In the end, the problem was isolated to a
mis-use of getContentLength(), where the author wanted to do something
only when a POST contained a body.
He used the following code to achieve this:
if(httpServletRequest.getContentLength() > 0) {
// Do something
}
But the javadoc has a small caveat:
Returns the length, in bytes, of the request body and made available by
the input stream, or -1 if the length is not known.
In this case it wasn't known because the clients used chunked encoding.
What are your thought on a detector of this pattern? I know there are
some cases, where this evaluation does not pose any problems, but
generally, I don't believe getContentLength() will be the right approach
for testing for the presence of a body.
--
Andreas
_______________________________________________
Findbugs-discuss mailing list
Findbugs-discuss@...
https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss