ServletInputStream.dataAvailable() - returns the number of bytes that that
can be read without blocking
Question:
Does this imply that non blocking reads are not supposed to be available for
Readers?
Take a 2 byte character set, like UTF-16, and the client sends the first
byte only.
In this case, the, onDataAvailable() would trigger, dataAvailable() would
return 1, but ServletRequest.getReader().read() would not have any data to
return
It can't return -1 as the stream hasn't ended. How are we supposed to handle
this case?
It seems here that the method ServletInputStream.dataAvailable() could be
replaced by
ServletInputStream.available() - return the number of bytes that can be
read without blocking
Reader.ready() - return true if read() is guaranteed to not block