@Override
    public int read(byte[] b, int off, int len) {
      if (b == null) {
        throw new NullPointerException("Byte array is null");
      }
      if (off < 0 || len < 0 || len > b.length - off) {
        throw new IndexOutOfBoundsException("Invalid offset or length");
      }
      if (len == 0) {
        return 0;
      }

      int bytesRead = 0;
      while (currentBufferIndex < buffers.size() && bytesRead < len) {
        ByteBuffer currentBuffer = buffers.get(currentBufferIndex);
        int remaining = currentBuffer.remaining();
        if (remaining > 0) {
          int bytesToRead = Math.min(len - bytesRead, remaining);
          currentBuffer.get(b, off + bytesRead, bytesToRead);
          bytesRead += bytesToRead;
        } else {
          currentBufferIndex++;
        }
      }
      return bytesRead == 0 ? -1 : bytesRead; // Return -1 if no bytes were read
    }
A mock implementation of {@link MessageWriteSet} to help write to a {@link Store} and simulate cases where
IOException occurred.
ambry-store/src/test/java/com/github/ambry/store/MockMessageWriteSet.java