-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DIS 7 PDUs advertise zero length #68
Comments
Thank-you for the report @Updownquark . Are you interested in submitting a pull request? Any help is really appreciated. |
Sure, I can do that. Would you like me to remove the length field from either or both Pdu abstract base classes as well, or just fix the bug? I could deprecate the getter and setter to avoid potential backward compatibility issues with any code that uses this. FYI I forgot to mention that there's a fairly straightforward workaround for this bug, which is why I didn't fix it myself and submit the pull request already. Calling
before marshalling does the job. |
I think removing the pduLength field would be a good idea to remove confusion. |
…cating the getter and setter. Setter now does nothing, getter delegates to getMarshalledSize(). All uses of the field were replaced. Tested with EntityState and Acknowledge PDU types.
…ecating the getter and setter. Setter now does nothing, getter delegates to getMarshalledSize(). All uses of the field were replaced. Tested with EntityState and Acknowledge PDU types.
Fixed in #69 |
When marshalling instances of subclasses of edu.nps.moves.dis7.PduSuperclass, the length field is never initialized to anything but zero, so the marshalled PDU advertises length 0.
Further inspection reveals that this is also the case in the DIS 6 PDU types (the setPduLength() method is never called and the pduLength field is never set), but the marshalling code calls getLength(), which delegates to getMarshalledSize() (as opposed to getPduLength(), a getter for the field), calculating the PDU length instead of using the value of the length attribute.
It seems like the marshal call in DIS 7 should also be changed to use getMarshalledSize() or some delegate to it.
In both DIS 6 and 7 PDUs, the length field should probably be removed entirely. This is more robust than having to initialize a field anyway, especially for variable-length PDU types.
The text was updated successfully, but these errors were encountered: