[MDSAL-51] Binding Java API Generator -> NPE during code generation from specific yang models (package name is null for UnionType) Created: 05/Nov/14  Updated: 09/Mar/18  Resolved: 10/Mar/17

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

Type: Bug
Reporter: Martin Ciglan Assignee: Martin Ciglan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
blocks MDSAL-40 Milestone: Implement Binding Specific... Resolved
Duplicate
is duplicated by YANGTOOLS-401 Restricted leaf's union type - Java A... Resolved
External issue ID: 2323

 Description   

[ERROR] yang-to-sources: Unable to generate sources with org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl generator
java.lang.IllegalArgumentException: Type cannot have Package Name referenced as NULL!
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
at org.opendaylight.yangtools.sal.java.api.generator.GeneratorUtil.putTypeIntoImports(GeneratorUtil.java:138)

package name cannot be null, problem with hard-coded UnionType class:

public static final class UnionType implements Type {
@Override
public String getPackageName() {
return null;
.
.
.
.
.



 Comments   
Comment by Martin Ciglan [ 23/Jan/15 ]

just to add, based on analysis of this issue:

error occurs when using imported typedef based on union type:

module module1 {

import module2

{ prefix m2; }

container foo {
leaf address {
type m2:host {
}
}
}
}

module module2 {
typedef host {
type union

{ type int8; type string; }

}
}

Error doesn't occur if:
1) imported typedef is not based on union type

typedef host

{ type string; }

2) typedef host is inside of module1

Comment by Vratko Polak [ 04/Jul/16 ]

Currently developed openconfig models trigger this Bug.
(Several of the models, mostly related to BGP, RIB and MPLS.)
https://github.com/openconfig/public

Comment by Martin Ciglan [ 10/Feb/17 ]

being fixed as part of types resolution within Binding generator for v2

Comment by Martin Ciglan [ 08/Mar/17 ]

fix pushed:

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

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