aeron-client/src/main/java/io/aeron/logbuffer/TermGapFiller.java
public static boolean tryFillGap(
        final UnsafeBuffer logMetaDataBuffer,
        final UnsafeBuffer termBuffer,
        final int termId,
        final int gapOffset,
        final int gapLength)
    {
        int offset = (gapOffset + gapLength) - FRAME_ALIGNMENT;

        while (offset >= gapOffset)
        {
            if (0 != termBuffer.getInt(offset))
            {
                return false;
            }

            offset -= FRAME_ALIGNMENT;
        }

        applyDefaultHeader(logMetaDataBuffer, termBuffer, gapOffset);
        frameType(termBuffer, gapOffset, HDR_TYPE_PAD);
        frameTermOffset(termBuffer, gapOffset);
        frameTermId(termBuffer, gapOffset, termId);
        frameLengthOrdered(termBuffer, gapOffset, gapLength);

        return true;
    }
public static boolean tryFillGap(
        final UnsafeBuffer logMetaDataBuffer,
        final UnsafeBuffer termBuffer,
        final int termId,
        final int gapOffset,
        final int gapLength)
    {
        int offset = (gapOffset + gapLength) - FRAME_ALIGNMENT;

        while (offset >= gapOffset)
        {
            if (0 != termBuffer.getInt(offset))
            {
                return false;
            }

            offset -= FRAME_ALIGNMENT;
        }

        applyDefaultHeader(logMetaDataBuffer, termBuffer, gapOffset);
        frameType(termBuffer, gapOffset, HDR_TYPE_PAD);
        frameTermOffset(termBuffer, gapOffset);
        frameTermId(termBuffer, gapOffset, termId);
        frameLengthOrdered(termBuffer, gapOffset, gapLength);

        return true;
    }
Try to gap fill the current term at a given offset if the gap contains no data.
<p>
Note: the gap offset plus gap length must end on a {@link FrameDescriptor#FRAME_ALIGNMENT} boundary.

@param logMetaDataBuffer containing the default headers
@param termBuffer        to gap fill
@param termId            for the current term.
@param gapOffset         to fill from
@param gapLength         to length of the gap.
@return true if the gap has been filled with a padding record or false if data found.