[YANGTOOLS-596] Make bits serialization sorted (by position) Created: 18/Mar/16  Updated: 10/Apr/22  Resolved: 18/Oct/16

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Vratko Polak Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 5561

 Description   

Yang specification describes canonical form for bits to be ordered by position: http://tools.ietf.org/html/rfc6020#section-9.7.3

But yang-data-api specifies:
public interface BitsCodec<T> extends Codec<T, Set<String>>{
and Set loses the ordering.
This makes ODL report bits in pseudorandom order, which is not nice as users need more logic to compare outputs, or convert them to canonical form if needed.

getBits() of BitsTypeDefinition already is a List, so it can preserve given ordering. But BitsCodes API change is required to make the ordering visible for serialization. Also, BitsTypeBuilder.build() is already aware of positions, but it does not use this information when passing arguments to constructor of BaseBitsType (usinging positionMap as a TreeMap could fix that).

As this improvement requires an API change, it could be done as part of Binding Specification v2 initiative.



 Comments   
Comment by Robert Varga [ 05/Sep/16 ]

java.util.Set does not specify iteration order, it only defines hashCode() and equals(). Iteration order is a property of an implementation and there certainly are implementations which have predictable iteration order: ImmutableSet, LinkedHashSet, for example.

Hence there is no need to change APIs.

Comment by Robert Varga [ 05/Sep/16 ]

master: https://bugs.opendaylight.org/show_bug.cgi?id=5561

Comment by Robert Varga [ 05/Sep/16 ]

master: https://git.opendaylight.org/gerrit/45158

Comment by Robert Varga [ 05/Sep/16 ]

mdsal part for BA->BI: https://git.opendaylight.org/gerrit/45158

Comment by Robert Varga [ 08/Sep/16 ]

last link should be https://git.opendaylight.org/gerrit/#/c/45161/

Comment by Ryan Goulding [ 18/Oct/16 ]

https://git.opendaylight.org/gerrit/#/c/47014/

Generated at Wed Feb 07 20:53:43 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.