[YANGTOOLS-1050] Leafref resolution breaks down on leafref involving deref() Created: 22/Dec/19 Updated: 10/Apr/22 Resolved: 24/Dec/19 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 4.0.3, 3.0.7, 2.1.14 |
| Fix Version/s: | 4.0.4, 3.0.8 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The following model:
module opendaylight-leafref-deref {
yang-version 1.1;
namespace "urn:opendaylight:leafref:deref";
prefix test;
identity target-base;
typedef target-type {
type identityref {
base target-base;
}
}
grouping grp {
leaf id {
type string;
}
leaf type {
type target-type;
}
list secondary {
key "id type";
leaf id {
type leafref {
path "/grp-uses/id";
}
}
leaf type {
type leafref {
path "deref(../id)/../type";
}
}
}
}
list grp-uses {
uses grp;
key "id type";
}
}
causes a StackOverflowError:
Exception in thread "main" java.lang.StackOverflowError
at com.google.common.base.CharMatcher$BitSetMatcher.matches(CharMatcher.java:997)
at org.opendaylight.yangtools.yang.common.AbstractQName.checkLocalName(AbstractQName.java:69)
at org.opendaylight.yangtools.yang.common.QName.create(QName.java:116)
at org.opendaylight.yangtools.yang.common.QName.create(QName.java:142)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.stringPathPartToQName(SchemaContextUtil.java:548)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.lambda$resolveRelativeXPath$2(SchemaContextUtil.java:615)
at com.google.common.collect.Iterators$6.transform(Iterators.java:783)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)
at com.google.common.collect.Iterators$ConcatenatedIterator.next(Iterators.java:1361)
at com.google.common.collect.Iterables$6$1.next(Iterables.java:882)
at com.google.common.collect.Iterables$6$1.next(Iterables.java:882)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeIn(SchemaContextUtil.java:364)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeIn(SchemaContextUtil.java:375)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInModule(SchemaContextUtil.java:333)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext(SchemaContextUtil.java:241)
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath(SchemaContextUtil.java:210)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.provideTypeForLeafref(AbstractTypeProvider.java:522)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForLeafrefOrIdentityRef(AbstractTypeProvider.java:302)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:196)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:159)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.resolveTypeFromDataSchemaNode(AbstractTypeProvider.java:726)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.provideTypeForLeafref(AbstractTypeProvider.java:564)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForLeafrefOrIdentityRef(AbstractTypeProvider.java:302)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:196)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:159)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.resolveTypeFromDataSchemaNode(AbstractTypeProvider.java:726)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.provideTypeForLeafref(AbstractTypeProvider.java:564)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForLeafrefOrIdentityRef(AbstractTypeProvider.java:302)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:196)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:159)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.resolveTypeFromDataSchemaNode(AbstractTypeProvider.java:726)
at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.provideTypeForLeafref(AbstractTypeProvider.java:564)
[...]
|
| Comments |
| Comment by Robert Varga [ 22/Dec/19 ] |
|
The leafref here is using an incompatible extension to RFC7950, i.e. the path is invalid as per RFC7950, but there is a request to add this functionality. |
| Comment by Robert Varga [ 22/Dec/19 ] |
|
I think SchemaContextUtil is getting confused here and resolves '/grp-uses/secondary/type' to itself, rather than '/grp-uses/type'. Note both have the same QName, hence it may work for different naming. |
| Comment by Robert Varga [ 23/Dec/19 ] |
|
Yeah, SchemaContextUtil.splitXPath() is doing the wrong thing as it does not actually dereference target leaf, just concatenates it – hence it ends up self-referencing. |