Skip to content

[Java] Compliation issue with generated decoder #713

Closed
@Qi7hao

Description

@Qi7hao

Hi,

With version 1.10.2, I noticed a compilation issue in the generated decoder.

My message schema (yaml) file is correctly parsed into xml file. Here is my message class in generic.xml (I omitted other non-optional fields in this class):

  <message name="MyMessageClass" id="10003" description="xx" semanticType="MyMessageClass">
    <other non-optional fields>
    <field xmlns="" name="myMessageAttribute" id="3" type="string16" semanticType="String" description="xx" presence="optional" sinceVersion="7"/>
  </message>

Here is a part of the auto generated MyMessageClassDecoder:

    public void getMyMessageAttribute(final Appendable value)
    {
        if (parentMessage.actingVersion < 7)
        {
            return "";
        }

        for (int i = 0; i < 16 ; ++i)
        {
            final int c = buffer.getByte(this.offset + 104 + i) & 0xFF;
            if (c == 0)
            {
                break;
            }
            try
            {
                value.append(c > 127 ? '?' : (char)c);
            }
            catch (final java.io.IOException e)
            {
                throw new java.io.UncheckedIOException(e);
            }
        }
    }

Apparently a void method should not return string.

This issue seems only happen to fields with type string (hence the decoder has getters that takes Appendable) and has the sinceVersion attribute (hence decoder checks for actingVersion in the getter method).

Thanks for looking into this.
Qihao

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