Is it ok to call ServletInputStream.getInputStream() multiple times in loop?

Encountered some code doing this inside a servlet:

while ((read = request.getInputStream().read(bytes)) != -1)

buffer.write(bytes, 0, read);

While in most cases, request.getInputStream() is just returning a field somewhere, I was thinking there might be dynamic wrappers or such that could get into a bad state.

Is there anything written in the docs about doing such a thing that I can use as a case for pulling the getInputStream() code out of the loop?...

Read More »

By: StackOverFlow - Monday, 3 December

Related Posts