Skip to content

Fix AggregateMarking.setCharacters() to preserve fixed 31-byte array - #42

Merged
ricklentz merged 1 commit into
masterfrom
fix/aggregate-marking-characters
Oct 7, 2026
Merged

ricklentz merged 1 commit into
masterfrom
fix/aggregate-marking-characters

Conversation

@ricklentz

Copy link
Copy Markdown
Collaborator

Summary

  • Use Arrays.copyOf() in AggregateMarking.setCharacters() to preserve the fixed 31-byte array length, matching EntityMarking.setCharacters()

Root cause

setCharacters() replaced the fixed 31-byte characters array with the caller's array (e.g. 8 bytes for "TestAgg1"). Marshal then wrote 8 bytes but unmarshal read 31, shifting all subsequent fields by 23 bytes and corrupting dimensions, orientation, centerOfMass, etc.

The XML definition for AggregateMarking.characters has length="31" but is missing fixedlength="true" (unlike EntityMarking), so the generator produced a non-safe setter. The upstream fix is in open-dis/opendis7-source-generator (separate PR).

Closes #35

Test plan

  • AggregateStatePduTest.testMultiplePdus() should now pass
  • Dimensions, orientation, centerOfMass, velocity all round-trip correctly

setCharacters() replaced the fixed 31-byte array with the caller's
array, causing marshal to write fewer bytes than unmarshal reads.
This byte-offset mismatch corrupted all subsequent fields including
dimensions, producing garbage values after network round-trip.

Use Arrays.copyOf() to preserve the fixed array length, matching
the pattern already used by EntityMarking.setCharacters().

Closes #35
@ricklentz
ricklentz merged commit c309498 into master Oct 7, 2026
1 check passed
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.

Java unit test problem with AggregateStatePduTest

1 participant