[MDSAL-599] Identify violating key component when checking null Created: 17/Oct/20  Updated: 19/Dec/20  Resolved: 24/Oct/20

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: None
Fix Version/s: 7.0.2

Type: Improvement Priority: High
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.


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