Skip to content

wrapAndApplyHeader doesnt respect constant fields in the MessageHeader #602

Closed
@kdkavanagh

Description

@kdkavanagh

I don't have a need for schemaID in the MessageHeader and have set it to a constant in the XML. This runs through the sbe-tool without complaints, however the generated wrapAndApplyHeader methods still try to apply the schemaID, ignoring the fact that it is a constant.

XML:

    <composite name="messageHeader" description="Message identifiers and length of message root">
        <type name="msgSize" primitiveType="uint16"/>
        <type name="templateId" primitiveType="uint16"/>
        <type name="version" primitiveType="uint16"/>
        <type name="blockLength" primitiveType="uint16"/>
        <type name="schemaId" primitiveType="uint16" presence="constant">1</type>
    </composite>

Generated java:

    public TestFixedWidthMessageEncoder wrapAndApplyHeader(
        final MutableDirectBuffer buffer, final int offset, final MessageHeaderEncoder headerEncoder)
    {
        headerEncoder
            .wrap(buffer, offset)
            .blockLength(BLOCK_LENGTH)
            .templateId(TEMPLATE_ID)
            .schemaId(SCHEMA_ID)
            .version(SCHEMA_VERSION);

        return wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions