Defer path stripping 39/86639/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 30 Dec 2019 11:29:31 +0000 (12:29 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 30 Dec 2019 21:18:16 +0000 (22:18 +0100)
If we are passed a relative path, we end up first stripping it
and then realizing it's relative. Invert the order, making absolute
proper invariant.

Change-Id: Ic272ac83a9df9d2343b1cd8c5f71debdcdc0faad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0236f96b973675555087801c0d786d7f19eee8f1)

yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java

index 2fa0a3ad230fc01163ef812ac6d08f394393a005..c047ead58f252add5b6803478d3304fa65de96e7 100644 (file)
@@ -875,12 +875,13 @@ public final class SchemaContextUtil {
     public static TypeDefinition<?> getBaseTypeForLeafRef(final LeafrefTypeDefinition typeDefinition,
             final SchemaContext schemaContext, final QName qname) {
         final PathExpression pathStatement = typeDefinition.getPathStatement();
     public static TypeDefinition<?> getBaseTypeForLeafRef(final LeafrefTypeDefinition typeDefinition,
             final SchemaContext schemaContext, final QName qname) {
         final PathExpression pathStatement = typeDefinition.getPathStatement();
-        final PathExpression strippedPathStatement = new PathExpressionImpl(
-            stripConditionsFromXPathString(pathStatement), pathStatement.isAbsolute());
-        if (!strippedPathStatement.isAbsolute()) {
+        if (!pathStatement.isAbsolute()) {
             return null;
         }
 
             return null;
         }
 
+        final PathExpression strippedPathStatement = new PathExpressionImpl(
+            stripConditionsFromXPathString(pathStatement), true);
+
         final Optional<Module> parentModule = schemaContext.findModule(qname.getModule());
         checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);
 
         final Optional<Module> parentModule = schemaContext.findModule(qname.getModule());
         checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);