Skip to content

[Java] Check sinceVersion for set choices when decoding - #1125

Open
aymenjam wants to merge 1 commit into
aeron-io:masterfrom
aymenjam:issue-1035-java-set-choice-since-version
Open

aymenjam wants to merge 1 commit into
aeron-io:masterfrom
aymenjam:issue-1035-java-set-choice-since-version

Conversation

@aymenjam

@aymenjam aymenjam commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #1035.

Problem

A set choice can have a sinceVersion attribute. 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 return true when we decode an older message.

Changes

  • The generated set decoder has a new actingVersion field. The default value is SCHEMA_VERSION.
  • The set decoder has a new method wrap(buffer, offset, actingVersion). The current wrap(buffer, offset) does not change.
  • Message and group decoders call the new wrap method with the acting version. Sets inside composites do not change.
  • A choice getter with sinceVersion > 0 returns false when the acting version is lower than sinceVersion.
  • getRaw(), isEmpty() and the encoders do not change.

Test

New test JavaGeneratorTest.shouldNotDecodeSetChoiceAddedAfterActingVersion with a new schema issue1035.xml. It sets both choice bits and decodes the message with version 0 and with version 1.

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
aymenjam force-pushed the issue-1035-java-set-choice-since-version branch from 4c57a0c to f997cc8 Compare October 2, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sinceVersion not respected for newly added choices in sets

1 participant