From 27e379b2b16e8ea3149dfde2c4226fd0a883592f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 28 Dec 2019 11:09:37 +0100 Subject: [PATCH] Issue an info message when a config=true list does not have keys RFC7950 section 7.8.2 places an explicit requirement that lists representing configuration (i.e. config=true) must define at least one key. This restriction does make sense in contexts like NETCONF, but is generally not needed in OpenDaylight. Since it hurts model interoperability, add a message pointing this violation out. JIRA: YANGTOOLS-957 Change-Id: If29078e51aa1ec55fa070f263755f15147ad835f Signed-off-by: Robert Varga (cherry picked from commit e9061a5ad89661154190aa7703b1de95a5fb528e) --- .../rfc7950/stmt/list/ListEffectiveStatementImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListEffectiveStatementImpl.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListEffectiveStatementImpl.java index 521c76d74f..528d0caf26 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListEffectiveStatementImpl.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListEffectiveStatementImpl.java @@ -38,6 +38,8 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveMust import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStmtUtils; import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Internal implementation of ListEffectiveStatement. @@ -50,6 +52,7 @@ public final class ListEffectiveStatementImpl extends AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer implements ListEffectiveStatement, ListSchemaNode, DerivableSchemaNode, ActionNodeContainerCompat, NotificationNodeContainerCompat { + private static final Logger LOG = LoggerFactory.getLogger(ListEffectiveStatementImpl.class); private static final String ORDER_BY_USER_KEYWORD = "user"; private final boolean userOrdered; @@ -95,6 +98,12 @@ public final class ListEffectiveStatementImpl this.keyDefinition = ImmutableList.of(); } + if (isConfiguration() && keyDefinition.isEmpty()) { + LOG.info("Configuration list {} does not define any keys in violation of RFC7950 section 7.8.2. While " + + " this is fine with OpenDaylight, it can cause interoperability issues with other systems " + + "[at {}]", ctx.getStatementArgument(), ctx.getStatementSourceReference()); + } + this.uniqueConstraints = ImmutableList.copyOf(allSubstatementsOfType(UniqueConstraint.class)); final Builder actionsBuilder = ImmutableSet.builder(); -- 2.36.6