@Override
  public int read(ByteBuffer dst) throws IOException {
    if (mClosed) {
      throw new ClosedChannelException();
    }
    int maxReadable = dst.remaining();
    int position = dst.position();
    synchronized (this) {
      ByteBuf buf = Unpooled.wrappedBuffer(dst);
      buf.writerIndex(0);
      int bytesRead = mReader.transferTo(buf);
      Preconditions.checkState(bytesRead <= maxReadable, "buffer overflow");
      if (bytesRead > 0) {
        dst.position(position + bytesRead);
      }
      return bytesRead;
    }
  }
@Test
  public void dependentInternalPosition() throws Exception {
    int dataSize = 100;
    ByteBuffer buffer = ByteBuffer.allocate(dataSize);
    buffer.clear();
    assertEquals(dataSize, IOUtils.read(mChannel, buffer));
    buffer.flip();
    assertTrue(BufferUtils.equalIncreasingByteBuffer(0, dataSize, buffer));

    buffer.clear();
    ByteBuf buf = Unpooled.wrappedBuffer(buffer);
    buf.writerIndex(0);
    assertEquals(dataSize, mReader.transferTo(buf));
    assertTrue(BufferUtils.equalIncreasingByteBuffer(dataSize, dataSize, buffer));
  }