Skip to content

PDU unmarshal duplicates list entries when called on reused objects #32

@ricklentz

Description

@ricklentz

Bug

Six PDU tests report "String mismatch" failures due to duplicated list entries after unmarshal:

  • EventReportPduTest
  • ActionRequestPduTest
  • ActionResponsePduTest
  • AggregateStatePduTest
  • MinefieldDataPduTest
  • ResupplyReceivedPduTest

Root Cause

The generated unmarshal() methods (both DataInputStream and ByteBuffer variants) call .add() on list fields without first calling .clear(). When unmarshal() is called on a PDU object that already contains data, the new entries are appended to the existing ones instead of replacing them.

Fix

The fix is in opendis7-source-generator — the JavaGenerator.java template needs to emit a .clear() call on each list field before the unmarshal for-loop. After regeneration, all affected PDU classes will produce correct unmarshal code.

Affected PDU Fields

  • EventReportPdu: fixedDatums, variableDatums
  • ActionRequestPdu: fixedDatums, variableDatums
  • ActionResponsePdu: fixedDatums, variableDatums
  • AggregateStatePdu: aggregateIDList, entityIDList, silentAggregateSystemList, silentEntitySystemList, variableDatumList
  • MinefieldDataPdu: sensorTypes, mineLocation
  • ResupplyReceivedPdu: supplies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions