X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FDOMRpcRouter.java;h=14e75e22c6c6572f62f802901bd0e9e356d93097;hb=2b2ee780fded7fca2d2a3e4695e3aec7f6c1bcc2;hp=d72f714a5f83d8b061697ce599c5c0d9748db7ad;hpb=e3998d55e33da9f6ecb69da75ecc71a047b6362b;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