public void commit(final int index)
    {
        final int recordIndex = computeRecordIndex(index);
        final AtomicBuffer buffer = this.buffer;
        final int recordLength = verifyClaimedSpaceNotReleased(buffer, recordIndex);

        buffer.putIntOrdered(lengthOffset(recordIndex), -recordLength);
    }
@Test
    void commitPublishesMessageByInvertingTheLengthValue()
    {
        final int index = 128;
        final int recordIndex = index - HEADER_LENGTH;
        final int recordLength = -19;
        when(buffer.getInt(lengthOffset(recordIndex))).thenReturn(recordLength);

        ringBuffer.commit(index);

        final InOrder inOrder = inOrder(buffer);
        inOrder.verify(buffer).getInt(lengthOffset(recordIndex));
        inOrder.verify(buffer).putIntOrdered(lengthOffset(recordIndex), -recordLength);
        inOrder.verifyNoMoreInteractions();
    }