Repository navigation
Conversation
The Java set decoder did not know the acting version of the message. So a choice added in a newer version could return true when the decoder reads an older message. Now the set decoder has an actingVersion field and a new wrap(buffer, offset, actingVersion) method. Message and group decoders use this method. A choice getter returns false when the acting version is lower than the choice sinceVersion. This is the same behavior as in C and C++.
aymenjam
force-pushed
the
issue-1035-java-set-choice-since-version
branch
from
October 2, 2026 07:17
4c57a0c to
f997cc8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1035.
Problem
A set choice can have a
sinceVersionattribute. The C and C++ decoders check it. The Java decoder does not check it, because the Java set decoder does not know the acting version of the message. So a choice added in a newer version can returntruewhen we decode an older message.Changes
actingVersionfield. The default value isSCHEMA_VERSION.wrap(buffer, offset, actingVersion). The currentwrap(buffer, offset)does not change.wrapmethod with the acting version. Sets inside composites do not change.sinceVersion > 0returnsfalsewhen the acting version is lower thansinceVersion.getRaw(),isEmpty()and the encoders do not change.Test
New test
JavaGeneratorTest.shouldNotDecodeSetChoiceAddedAfterActingVersionwith a new schemaissue1035.xml. It sets both choice bits and decodes the message with version 0 and with version 1.