From: Tom Pantelis Date: Sun, 22 Jul 2018 15:18:26 +0000 (-0400) Subject: Fix DOMRpcRouter breakage X-Git-Tag: release/fluorine~29 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=refs%2Fchanges%2F12%2F74312%2F1;hp=19dda47fc3d00213fbddd3c6a70cbb5b3c898c8a Fix DOMRpcRouter breakage https://git.opendaylight.org/gerrit/#/c/74209/ broke the DOMRpcRouter for UTs that use the empty constructor. The mdsal DOMRpcRouter no longer implements DOMRpcProviderService directly so the SchemaContext was not getting set via onGlobalContextUpdated. Change-Id: Ic9381742f43b05264724eb80eef41201a1285c2a Signed-off-by: Tom Pantelis --- diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java index f95ef1a936..6446cbd3ae 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java @@ -43,17 +43,24 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP private final org.opendaylight.mdsal.dom.api.DOMRpcService delegateRpcService; private final org.opendaylight.mdsal.dom.api.DOMRpcProviderService delegateRpcProviderService; + // Note - this is only used for backward compatibility for UTs that use the empty constructor which creates + // a local mdsal DOMRpcRouter that needs to be updated with the SchemaContext. In production, the mdsal API + // services are passed via the constructor and are set up externally with the SchemaContext. + private final SchemaContextListener delegateSchemaContextListener; + @VisibleForTesting public DOMRpcRouter() { org.opendaylight.mdsal.dom.broker.DOMRpcRouter delegate = new org.opendaylight.mdsal.dom.broker.DOMRpcRouter(); this.delegateRpcService = delegate.getRpcService(); this.delegateRpcProviderService = delegate.getRpcProviderService(); + this.delegateSchemaContextListener = delegate; } public DOMRpcRouter(final org.opendaylight.mdsal.dom.api.DOMRpcService delegateRpcService, final org.opendaylight.mdsal.dom.api.DOMRpcProviderService delegateRpcProviderService) { this.delegateRpcService = delegateRpcService; this.delegateRpcProviderService = delegateRpcProviderService; + this.delegateSchemaContextListener = null; } @Override @@ -159,8 +166,8 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP @Override @VisibleForTesting public void onGlobalContextUpdated(final SchemaContext context) { - if (delegateRpcService instanceof SchemaContextListener) { - ((SchemaContextListener)delegateRpcService).onGlobalContextUpdated(context); + if (delegateSchemaContextListener != null) { + delegateSchemaContextListener.onGlobalContextUpdated(context); } } }