code: private void adjustChecksumBytes(int dataLen) {
      int requiredSize =
        ((dataLen + bytesPerChecksum - 1)/bytesPerChecksum)*checksumSize;
      if (checksumBytes == null || requiredSize > checksumBytes.capacity()) {
        checksumBytes =  ByteBuffer.wrap(new byte[requiredSize]);
      } else {
        checksumBytes.clear();
      }
      checksumBytes.limit(requiredSize);
    }
docs: Makes sure that checksumBytes has enough capacity
  and limit is set to the number of checksum bytes needed
  to be read.