aeron-client/src/main/java/io/aeron/logbuffer/TermGapScanner.java
public static int scanForGap(
        final UnsafeBuffer termBuffer,
        final int termId,
        final int termOffset,
        final int limitOffset,
        final GapHandler handler)
    {
        int offset = termOffset;
        do
        {
            final int frameLength = frameLengthVolatile(termBuffer, offset);
            if (frameLength <= 0)
            {
                break;
            }

            offset += align(frameLength, FRAME_ALIGNMENT);
        }
        while (offset < limitOffset);

        final int gapBeginOffset = offset;
        if (offset < limitOffset)
        {
            final int limit = limitOffset - ALIGNED_HEADER_LENGTH;
            while (offset < limit)
            {
                offset += FRAME_ALIGNMENT;

                if (0 != termBuffer.getIntVolatile(offset))
                {
                    offset -= ALIGNED_HEADER_LENGTH;
                    break;
                }
            }

            final int gapLength = (offset - gapBeginOffset) + ALIGNED_HEADER_LENGTH;
            handler.onGap(termId, gapBeginOffset, gapLength);
        }

        return gapBeginOffset;
    }
public static int scanForGap(
        final UnsafeBuffer termBuffer,
        final int termId,
        final int termOffset,
        final int limitOffset,
        final GapHandler handler)
    {
        int offset = termOffset;
        do
        {
            final int frameLength = frameLengthVolatile(termBuffer, offset);
            if (frameLength <= 0)
            {
                break;
            }

            offset += align(frameLength, FRAME_ALIGNMENT);
        }
        while (offset < limitOffset);

        final int gapBeginOffset = offset;
        if (offset < limitOffset)
        {
            final int limit = limitOffset - ALIGNED_HEADER_LENGTH;
            while (offset < limit)
            {
                offset += FRAME_ALIGNMENT;

                if (0 != termBuffer.getIntVolatile(offset))
                {
                    offset -= ALIGNED_HEADER_LENGTH;
                    break;
                }
            }

            final int gapLength = (offset - gapBeginOffset) + ALIGNED_HEADER_LENGTH;
            handler.onGap(termId, gapBeginOffset, gapLength);
        }

        return gapBeginOffset;
    }
public static int scanForGap ( final UnsafeBuffer termBuffer , final int termId , final int termOffset , final int limitOffset , final GapHandler handler ) { int offset = termOffset ; do { final int frameLength = frameLengthVolatile ( termBuffer , offset ) ; if ( frameLength <= 0 ) { break ; } offset += align ( frameLength , FRAME_ALIGNMENT ) ; } while ( offset < limitOffset ) ; final int gapBeginOffset = offset ; if ( offset < limitOffset ) { final int limit = limitOffset - ALIGNED_HEADER_LENGTH ; while ( offset < limit ) { offset += FRAME_ALIGNMENT ; if ( 0 != termBuffer . getIntVolatile ( offset ) ) { offset -= ALIGNED_HEADER_LENGTH ; break ; } } final int gapLength = ( offset - gapBeginOffset ) + ALIGNED_HEADER_LENGTH ; handler . onGap ( termId , gapBeginOffset , gapLength ) ; } return gapBeginOffset ; }
Scan for gaps from the scanOffset up to a limit offset. Each gap will be reported to the {@link GapHandler}.

@param termBuffer  to be scanned for a gap.
@param termId      of the current term buffer.
@param termOffset  at which to start scanning.
@param limitOffset at which to stop scanning.
@param handler     to call if a gap is found.
@return offset of last contiguous frame
Scan for gaps from the scanOffset up to a limit offset . Each gap will be reported to the { @link GapHandler } .