real-logic / simple-binary-encoding

Simple Binary Encoding (SBE) - High Performance Message Codec
Apache License 2.0
3.08k stars 519 forks source link

[Java] Invalid toString generated for messages having names starting with a lower case letter #745

Closed wojciech-adaptive closed 4 years ago

wojciech-adaptive commented 4 years ago

For a schema with messages having names starting with a lower case letter, e.g.:

<?xml version="1.0" encoding="UTF-8"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
                   xmlns:xi="http://www.w3.org/2001/XInclude"
                   package="baseline"
                   id="1"
                   version="0"
                   semanticVersion="5.2"
                   description="Schema with lowercase message name."
                   byteOrder="littleEndian">

    <types>
        <composite name="messageHeader" description="Message identifiers and length of message root.">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="templateId" primitiveType="uint16"/>
            <type name="schemaId" primitiveType="uint16"/>
            <type name="version" primitiveType="uint16"/>
        </composite>
        <composite name="groupSizeEncoding" description="Repeating group dimensions.">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="numInGroup" primitiveType="uint16"/>
        </composite>
        <composite name="varStringEncoding" description="Variable length UTF-8 String.">
            <type name="length" primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData" primitiveType="uint8" length="0" characterEncoding="UTF-8"/>
        </composite>
        <composite name="varAsciiEncoding" description="Variable length ASCII String.">
            <type name="length" primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData" primitiveType="uint8" length="0" characterEncoding="ASCII"/>
        </composite>
        <composite name="varDataEncoding" description="Variable length binary blob.">
            <type name="length" primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData" primitiveType="uint8" length="0"/>
        </composite>
    </types>

    <sbe:message name="foo" id="1" description="Foo type.">
        <field name="id" id="1" type="uint64"/>
    </sbe:message>
</sbe:messageSchema>

SBE 1.16.0 generates invalid toString in FooDecoder:

public String toString()
{
    fooDecoder decoder = new fooDecoder(); // doesn't compile: error: cannot find symbol
    decoder.wrap(buffer, initialOffset, BLOCK_LENGTH, SCHEMA_VERSION);

    return decoder.appendTo(new StringBuilder()).toString();
}
mjpt777 commented 4 years ago

Fixed with this commit. https://github.com/real-logic/simple-binary-encoding/commit/c55ee4db53e3ff9d00317da8125de77923e0087e