public synchronized void rewind() {
        this.readPosition = 0;
        this.curReadBufferIndex = 0;
        this.readPosInCurBuffer = 0;
        if (CollectionUtils.isNotEmpty(bufferList)) {
            this.curBuffer = bufferList.get(0);
            for (ByteBuffer buffer : bufferList) {
                buffer.rewind();
            }
        }
    }
@Test
    public void testCommitLogTypeInputStreamWithCoda() {
        List<ByteBuffer> uploadBufferList = new ArrayList<>();
        int bufferSize = 0;
        for (int i = 0; i < MSG_NUM; i++) {
            ByteBuffer byteBuffer = MessageFormatUtilTest.buildMockedMessageBuffer();
            uploadBufferList.add(byteBuffer);
            bufferSize += byteBuffer.remaining();
        }

        ByteBuffer codaBuffer = ByteBuffer.allocate(MessageFormatUtil.COMMIT_LOG_CODA_SIZE);
        codaBuffer.putInt(MessageFormatUtil.COMMIT_LOG_CODA_SIZE);
        codaBuffer.putInt(MessageFormatUtil.BLANK_MAGIC_CODE);
        long timeMillis = System.currentTimeMillis();
        codaBuffer.putLong(timeMillis);
        codaBuffer.flip();
        int codaBufferSize = codaBuffer.remaining();
        bufferSize += codaBufferSize;

        // build expected byte buffer for verifying the FileSegmentInputStream
        ByteBuffer expectedByteBuffer = ByteBuffer.allocate(bufferSize);
        for (ByteBuffer byteBuffer : uploadBufferList) {
            expectedByteBuffer.put(byteBuffer);
            byteBuffer.rewind();
        }
        expectedByteBuffer.put(codaBuffer);
        codaBuffer.rewind();
        // set real physical offset
        for (int i = 0; i < MSG_NUM; i++) {
            long physicalOffset = COMMIT_LOG_START_OFFSET + i * MSG_LEN;
            int position = i * MSG_LEN + MessageFormatUtil.PHYSICAL_OFFSET_POSITION;
            expectedByteBuffer.putLong(position, physicalOffset);
        }

        int finalBufferSize = bufferSize;
        int[] batchReadSizeTestSet = {
            MessageFormatUtil.PHYSICAL_OFFSET_POSITION - 1, MessageFormatUtil.PHYSICAL_OFFSET_POSITION, MessageFormatUtil.PHYSICAL_OFFSET_POSITION + 1,
            MSG_LEN - 1, MSG_LEN, MSG_LEN + 1,
            bufferSize - 1, bufferSize, bufferSize + 1
        };
        verifyReadAndReset(expectedByteBuffer, () -> FileSegmentInputStreamFactory.build(
            FileSegmentType.COMMIT_LOG, COMMIT_LOG_START_OFFSET, uploadBufferList, codaBuffer, finalBufferSize), finalBufferSize, batchReadSizeTestSet);

    }