code: @Override
      public synchronized int read(final byte buf[], final int off, final int len)
              throws IOException {
          while (this.currentRecord.needsData()) {
              final byte[] data = new byte[len];
              final int read = this.inputStream.read(data);
              if (read == -1) {
                  return read;
              }
              lastBuffer = ByteBuffer.wrap(data, 0, read);
              this.currentRecord.addData(lastBuffer);
          }
          final int bytesRead = this.currentRecord.drainData(buf, off, len);
          if (!this.currentRecord.hasMoreData()) {
              LOG.info("Resetting app record");
              this.currentRecord = new InputRecord(readKey);
              if (lastBuffer != null) {
                  this.currentRecord.addData(lastBuffer);
              } else {
                  LOG.warn("No existing buffer?");
              }
          }
          return bytesRead;
      }
docs: Read up to "len" bytes into this buffer, starting at "off".
  If the layer above needs more data, it asks for more, so we
  are responsible only for blocking to fill at most one buffer,
  and returning "-1" on non-fault EOF status.