X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FDOMRpcRouter.java;h=14e75e22c6c6572f62f802901bd0e9e356d93097;hb=03e639ec0e4b1b2a55a8763b5642b1118e52861c;hp=d72f714a5f83d8b061697ce599c5c0d9748db7ad;hpb=c31509c7a6630e54a9f9749a643fed5e1a1ad380;p=controller.git 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 d72f714a5f..14e75e22c6 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 @@ -67,22 +67,23 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP final DOMRpcRoutingTable newTable = oldTable.remove(implementation, rpcs); final Collection removedRpcs = notPresentRpcs(newTable, rpcs); - final Collection> capturedListeners = listeners; routingTable = newTable; - - listenerNotifier.execute(new Runnable() { - @Override - public void run() { - for (ListenerRegistration l : capturedListeners) { - // Need to ensure removed listeners do not get notified - synchronized (DOMRpcRouter.this) { - if (listeners.contains(l)) { - l.getInstance().onRpcUnavailable(removedRpcs); + if(!removedRpcs.isEmpty()) { + final Collection> capturedListeners = listeners; + listenerNotifier.execute(new Runnable() { + @Override + public void run() { + for (final ListenerRegistration l : capturedListeners) { + // Need to ensure removed listeners do not get notified + synchronized (DOMRpcRouter.this) { + if (listeners.contains(l)) { + l.getInstance().onRpcUnavailable(removedRpcs); + } } } } - } - }); + }); + } } @Override @@ -91,22 +92,24 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP final DOMRpcRoutingTable newTable = oldTable.add(implementation, rpcs); final Collection addedRpcs = notPresentRpcs(oldTable, rpcs); - final Collection> capturedListeners = listeners; routingTable = newTable; - listenerNotifier.execute(new Runnable() { - @Override - public void run() { - for (ListenerRegistration l : capturedListeners) { - // Need to ensure removed listeners do not get notified - synchronized (DOMRpcRouter.this) { - if (listeners.contains(l)) { - l.getInstance().onRpcAvailable(addedRpcs); + if(!addedRpcs.isEmpty()) { + final Collection> capturedListeners = listeners; + listenerNotifier.execute(new Runnable() { + @Override + public void run() { + for (final ListenerRegistration l : capturedListeners) { + // Need to ensure removed listeners do not get notified + synchronized (DOMRpcRouter.this) { + if (listeners.contains(l)) { + l.getInstance().onRpcAvailable(addedRpcs); + } } } } - } - }); + }); + } return new AbstractDOMRpcImplementationRegistration(implementation) { @Override