@Override
    public int read(byte[] b, int off, int len) throws IOException {
      ByteBuffer bb = waitForAvailableData();
      int remaining = bb.remaining();
      int bytesToRead = len;
      if (remaining < len) {
        bytesToRead = remaining;
      }
      bb.get(b, off, bytesToRead);
      // logit("read[] read=" + bytesToRead);
      return bytesToRead;
    }
See the InputStream read method for javadocs. Note that if an attempt to read past the end of
the wrapped ByteBuffer is done this method throws BufferUnderflowException
geode-core/src/main/java/org/apache/geode/internal/tcp/MsgDestreamer.java