You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When upgrading to SBE 1.6.1 from 1.6.0, two of our backwards compatibility tests failed.
Looking into this in more detail, we believe it is to do with commit 6852773
Given version 1 of a schema
<?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
<messageSchemapackage="com.transficc.sbecompatibility.test2.protocol.v1"id="0"version="1"semanticVersion="1.0"description="Unit Test For Compatibility"byteOrder="littleEndian">
<types>
<compositename="messageHeader"description="Message identifiers and length of message root">
<typename="blockLength"primitiveType="uint16"/>
<typename="templateId"primitiveType="uint16"/>
<typename="schemaId"primitiveType="uint16"/>
<typename="version"primitiveType="uint16"/>
</composite>
<compositename="groupSizeEncoding"description="Repeating group dimensions">
<typename="blockLength"primitiveType="uint16"/>
<typename="numInGroup"primitiveType="uint8"semanticType="NumInGroup"/>
</composite>
</types>
<messagename="Message"id="2"description="Message">
<fieldname="longField1"id="0100000000"type="int64"/>
<groupdimensionType="groupSizeEncoding"name="group1"id="0300000000">
<fieldname="longField1"id="0301000000"type="int64"/>
</group>
</message>
</messageSchema>
And version 2 of the schema where we add a nested group
<?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
<messageSchemapackage="com.transficc.sbecompatibility.test2.protocol.v2"id="0"version="2"semanticVersion="1.1"description="Unit Test For Compatibility"byteOrder="littleEndian">
<types>
<compositename="messageHeader"description="Message identifiers and length of message root">
<typename="blockLength"primitiveType="uint16"/>
<typename="templateId"primitiveType="uint16"/>
<typename="schemaId"primitiveType="uint16"/>
<typename="version"primitiveType="uint16"/>
</composite>
<compositename="groupSizeEncoding"description="Repeating group dimensions">
<typename="blockLength"primitiveType="uint16"/>
<typename="numInGroup"primitiveType="uint8"semanticType="NumInGroup"/>
</composite>
</types>
<messagename="Message"id="2"description="Message">
<fieldname="longField1"id="0100000000"type="int64"/>
<groupdimensionType="groupSizeEncoding"name="group1"id="0300000000">
<fieldname="longField1"id="0301000000"type="int64"/>
<groupdimensionType="groupSizeEncoding"name="nestedGroup"id="0304000000"presence="optional"sinceVersion="2">
<fieldname="longField1"id="0304010000"type="int64"presence="optional"sinceVersion="2"/>
</group>
</group>
</message>
</messageSchema>
When we use the version 1 encoder to encode a message and the version 2 decode to decode the message, the generated decoder for the nested group thinks there is an entry for the repeated group and attempts to decode. This occurs because the hasNext has been changed to check return index < count rather than return (index + 1) < count;\n"
I have a unit test that proves this but wasn't sure where in the SBE code base to to add:
@TestvoidshouldNotAttemptToDecodeNestedGroupForMessageEncodedUsingV1Encoder()
{
finalintexpectedLongField1Value = 435;
finalintexpectedGroupCount = 1;
finalintexpectedGroupLongField1Value = 678;
finalintexpectedNestedGroupCount = 0;
finalMutableDirectBufferbuffer = newExpandableArrayBuffer(1024);
//Encode using v1 encoderfinalMessageEncoderv1MessageEncoder = newMessageEncoder();
finalMessageHeaderEncoderv1HeaderEncoder = newMessageHeaderEncoder();
v1MessageEncoder.wrapAndApplyHeader(buffer, OFFSET, v1HeaderEncoder);
v1MessageEncoder.longField1(expectedLongField1Value);
finalMessageEncoder.Group1Encodergroup1Encoder = v1MessageEncoder.group1Count(expectedGroupCount);
group1Encoder
.next()
.longField1(expectedGroupLongField1Value);
//Decode using v2 decodefinalMessageDecoderv2MessageDecoder = newMessageDecoder();
finalMessageHeaderDecoderv2HeaderDecoder = newMessageHeaderDecoder();
v2HeaderDecoder.wrap(buffer, OFFSET);
v2MessageDecoder.wrap(buffer, OFFSET + v2HeaderDecoder.encodedLength(), v2HeaderDecoder.blockLength(), v2HeaderDecoder.version());
Assertions.assertEquals(expectedLongField1Value, v2MessageDecoder.longField1());
finalMessageDecoder.Group1Decoderv2Group1Decoder = v2MessageDecoder.group1();
Assertions.assertEquals(expectedGroupCount, v2Group1Decoder.count());
for (finalMessageDecoder.Group1Decoderdecoder : v2Group1Decoder)
{
Assertions.assertEquals(expectedGroupLongField1Value, decoder.longField1());
finalMessageDecoder.Group1Decoder.NestedGroupDecoderv2NestedGroupDecoder1 = decoder.nestedGroup();
Assertions.assertEquals(v2NestedGroupDecoder1.count(), expectedNestedGroupCount);
for (finalMessageDecoder.Group1Decoder.NestedGroupDecodernestedGroupDecoder : v2NestedGroupDecoder1)
{
finallongnestedGroupField = nestedGroupDecoder.longField1();
Assertions.fail("Should never enter this loop. Read value for nested group field: " + nestedGroupField);
}
}
}
Was this change in behaviour expected / intentional?
Thanks,
Tom
The text was updated successfully, but these errors were encountered:
Your v2 schema does not pass validation because optional groups are not valid. SBE 1.0 does not support extension via groups or var-data. The real-logic implementation a little more flexible but we don't test for things outside the spec.
That being said I've pushed a change which should allow the old behaviour.
Hi,
When upgrading to SBE 1.6.1 from 1.6.0, two of our backwards compatibility tests failed.
Looking into this in more detail, we believe it is to do with commit 6852773
Given version 1 of a schema
And version 2 of the schema where we add a nested group
When we use the version 1 encoder to encode a message and the version 2 decode to decode the message, the generated decoder for the nested group thinks there is an entry for the repeated group and attempts to decode. This occurs because the
hasNext
has been changed to checkreturn index < count
rather thanreturn (index + 1) < count;\n"
I have a unit test that proves this but wasn't sure where in the SBE code base to to add:
Was this change in behaviour expected / intentional?
Thanks,
Tom
The text was updated successfully, but these errors were encountered: