Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

HY-73: bugfix when resetting groups decoder, then old group reference… #535

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -416,28 +416,21 @@ protected String resetGroup(final Entry entry)
" {\n" +
" for (final %2$s %6$s : %5$s.iterator())\n" +
" {\n" +
" %6$s.reset();\n" +
" if (%6$s.next() == null)\n" +
" {\n" +
" %6$s.reset();\n" +
" break;\n" +
" }\n" +
" else\n" +
" {\n" +
" %6$s.reset();\n" +
" }\n" +
" }\n" +
" %3$s = MISSING_INT;\n" +
" has%4$s = false;\n" +
" %7$s = null;\n" +
" }\n\n",
resetMethod,
decoderClassName(name),
formatPropertyName(numberField.name()),
numberField.name(),
iteratorFieldName(group),
formatPropertyName(decoderClassName(name)),
formatPropertyName(name)
);
formatPropertyName(decoderClassName(name)));
}
}

Expand Down Expand Up @@ -491,9 +484,6 @@ private String additionalReset(final boolean isGroup)
{
return
" buffer = null;\n" +
(isGroup ?
" next = null;\n" : ""
) +
" if (" + CODEC_VALIDATION_ENABLED + ")\n" +
" {\n" +
" invalidTagId = Decoder.NO_ERROR;\n" +
Expand Down Expand Up @@ -1743,6 +1733,7 @@ private String generateDecodePrefix(
" this.buffer = buffer;\n" +
" final int end = offset + length;\n" +
" int position = offset;\n" +
" int positionIter = position;\n" +
(hasCommonCompounds ? " position += header.decode(buffer, position, length);\n" : "") +
(isGroup ? " seenFields.clear();\n" : "") +
" int tag;\n\n" +
Expand Down Expand Up @@ -1921,7 +1912,17 @@ private String decodeGroup(final Entry entry)
" {\n" +
" if (%1$sCurrent != null)\n" +
" {\n" +
" position += %1$sCurrent.decode(buffer, position, end - position);\n" +
" positionIter = %1$sCurrent.decode(buffer, position, end - position);\n" +
" if (positionIter == 0 && " + CODEC_VALIDATION_ENABLED + ")\n" +
" {\n" +
" invalidTagId = tag;\n" +
" rejectReason = " + INCORRECT_NUMINGROUP_COUNT_FOR_REPEATING_GROUP + ";\n" +
" break;\n" +
" }\n" +
" else\n" +
" {\n" +
" position += positionIter;\n" +
" }\n" +
" %1$sCurrent = %1$sCurrent.next();\n" +
" }\n" +
" }\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,14 @@ public void shouldResetAllNestedRepeatingGroupEntries() throws Exception
assertEquals(2, getNoEgGroupGroupCounter(decoder));

group = getEgGroup(decoder);
assertNull(getNestedGroup(group));

// Although the message does not have nestedEg tags, the decoders will remain
// This is to ensure allocation is done only when it's necessary to add new elements to a repeating group
// for more details see issue https://github.com/real-logic/artio/issues/532
assertNotNull(getNestedGroup(group));

group = next(group);
assertNull(getNestedGroup(group));
assertNotNull(getNestedGroup(group));
}

@Test
Expand Down
Loading