if (isNonblocking) {
buf = stream.readnonblock(length);
} else {
while ((buf == null || buf.length() == 0) && !stream.feof()) {
waitReadable(stream);
buf = stream.readpartial(length);
}
}
boolean empty = buf == null || buf.length() == 0;
ByteList newBuf = empty ? ByteList.EMPTY_BYTELIST.dup() : buf;