[MDSAL-505] Improve leafref cycle detection Created: 23/Dec/19 Updated: 19/Jan/24 |
|
| Status: | In Review |
| Project: | mdsal |
| Component/s: | Binding codegen |
| Affects Version/s: | None |
| Fix Version/s: | 13.0.1 |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Samuel Schneider |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Current detection of circular leafref chains relies on parsing the expression multiple times and attempting to detect when we arrive at the same leafref. We should be able to improve this by tracking which leafref leaf nodes we have traversed, using a simple Collection.contains() to check we re-encountering a leafref. |
| Comments |
| Comment by Samuel Schneider [ 19/Jun/23 ] |
|
rovarga
list neighbor {
description
"List of neighbors.";
leaf neighbor-id1 {
type leafref {
path "../../neighbor/neighbor-id2";
}
description "Neighbor.";
}
leaf neighbor-id2 {
type leafref {
path "../../neighbor/neighbor-id3";
}
description "Neighbor.";
}
leaf neighbor-id3 {
type leafref {
path "../../neighbor/neighbor-id1";
}
description "Neighbor.";
}
}
if so, attempt to generate from yang like this results in StackOverflowError.
Caused by: java.lang.StackOverflowError
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractTypeObjectGenerator.methodReturnElementType(AbstractTypeObjectGenerator.java)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.TypeReference$ResolvedLeafref.methodReturnType(TypeReference.java:61)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractTypeObjectGenerator.createMethodReturnElementType(AbstractTypeObjectGenerator.java:499)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractTypeObjectGenerator.methodReturnElementType(AbstractTypeObjectGenerator.java:485)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.TypeReference$ResolvedLeafref.methodReturnType(TypeReference.java:61)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractTypeObjectGenerator.createMethodReturnElementType(AbstractTypeObjectGenerator.java:499)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractTypeObjectGenerator.methodReturnElementType(AbstractTypeObjectGenerator.java:485)
at org.opendaylight.mdsal.binding.generator@12.0.0-SNAPSHOT/org.opendaylight.mdsal.binding.generator.impl.reactor.TypeReference$ResolvedLeafref.methodReturnType(TypeReference.java:61)
|