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

Identify violating key component when checking null

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • High
    • Resolution: Done
    • None
    • 7.0.2
    • Binding codegen

    Description

      When we are enforcing non-null keys we use a very generic "Supplied value may not be null".

      I.e. we have a stack trace:

       

      java.lang.NullPointerException: Supplied value may not be null
       at java.base/java.util.Objects.requireNonNull(Objects.java:246)
       at org.opendaylight.yangtools.yang.binding.CodeHelpers.requireValue(CodeHelpers.java:63)
       at org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey.<init>(FlowKey.java:18)
       at org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder$FlowImpl.<init>(FlowBuilder.java:514)

       

       

      from this code:

      public FlowKey(@NonNull FlowId _id) {
          CodeHelpers.requireValue(_id);
       
          this._id = _id;
      }

      so the code generator knows this is a key, and it knows each property's name, so this snippet should look like this:

      public FlowKey(@NonNull FlowId _id) {
          this._id = CodeHelpers.requireLeaf(_id, "id");
      }
      

      where "id" should be QName.getLocalName(). The resulting component should then report something like 'Key component "id" must not be null'.

      Since these properties can be copied through a lot of builders, from unkeyed to keyed lists, knowing the property name will go a long way.

      Attachments

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

        Activity

          People

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: