Menu

#12 TLVTable does not preserve ordering of optional parameters

v0.3.6
open
Usability (4)
6
2012-09-15
2007-07-13
No

At present if you decode a packet from a byte stream and then reencode the packet back into a byte stream, sometimes the ordering of the optional parameters changes. As a result, the assertion that 'assert(Arrays.equals(byteArray, encodePacket(decodePacket(byteArray))) == true)' does not work reliably.

It would be nice if the implementation of TLVTable was changed to preserve the ordering of optional parameters. This could be done very easily by changing the following line in TLVTable:

private Map map = new HashMap();

...to read...

private Map map = new LinkedHashMap();

Discussion

MongoDB Logo MongoDB