Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-273

Binding Data Codec: Java Implementation is not compatible with Binding DataObject Proxy for binary type

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • Carbon
    • None
    • None
    • Operating System: All
      Platform: All

    • 8806

    Description

      The java Implementation is not compatible with the corresponding binding dataObject proxy for binary type.
      It means that if a XX DataObject is constructed using its XXBuilder, you use its getter method to get the binay type value, the cloned byte[] is returned.
      If the dataObject is retrieved from datastore with databroker, the dataobject is a proxy of NormalizdeNode,and you use its getter method to get the binay type value, the real byte[] reference is returned which is the same reference as the one in NormalizdeNode.
      Now if you changed the byte[] reference such as the value of index 1, now the original NormalizdeNode will be affected. Is this a bug? Is the behavior desired? I think it should be the same behavior both of the java Implementation and the binding dataObject proxy.

      The reason bebind this behavior is that the ValueTypeCodec for binay type is NOOP_CODEC, whose source code is below:
      /**
      *

      • No-op Codec, Java YANG Binding uses same types as NormalizedNode model
      • for base YANG types, representing numbers, binary and strings.
        *
        *
        */
        public static final SchemaUnawareCodec NOOP_CODEC = new SchemaUnawareCodec() {

      @Override
      public Object serialize(final Object input)

      { return input; }

      @Override
      public Object deserialize(final Object input) { return input; }

      };

      As shown above, all of number and binary and string type all use NOOP_CODEC, but number and string is invariant, but the representation of binary type is byte array which is variant.

      The bug is a back door to change the value of binary type?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            wusandi@163.com wu sandi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: