From 2b2ee780fded7fca2d2a3e4695e3aec7f6c1bcc2 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Tue, 19 May 2015 11:48:49 +0200 Subject: [PATCH] Bug 3234: Do not notify empty Rpc implementation change. DOMRpcBroker was sending notifications with empty set of RPC added or removed. This is possible if registration for RPC already exists and another one was registered. Change-Id: Iab92d6f1e5c76a050dc00dee802e1698ca26eccc Signed-off-by: Tony Tkacik --- .../md/sal/dom/broker/impl/DOMRpcRouter.java | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) 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 -- 2.36.6