Move sending advertisement outside synchronized block
Change-Id: I1709fecbec5e6f5ac245b535c14a5c0b2aea2820
diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java
index 20849ed..c08246e 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java
@@ -530,10 +530,9 @@
private void handleAntiEntropyAdvertisement(AntiEntropyAdvertisement<K> ad) {
List<EventuallyConsistentMapEvent<K, V>> externalEvents;
+ boolean sync = false;
synchronized (this) {
- final NodeId sender = ad.sender();
-
externalEvents = antiEntropyCheckLocalItems(ad);
antiEntropyCheckLocalRemoved(ad);
@@ -543,20 +542,25 @@
// if remote ad has something unknown, actively sync
for (K key : ad.timestamps().keySet()) {
if (!items.containsKey(key)) {
- AntiEntropyAdvertisement<K> myAd = createAdvertisement();
- try {
- unicastMessage(sender, antiEntropyAdvertisementSubject,
- myAd);
- break;
- } catch (IOException e) {
- log.debug(
- "Failed to send reactive anti-entropy advertisement to {}",
- sender);
- }
+ sync = true;
+ break;
}
}
} // synchronized (this)
+ // Send the advertisement outside the synchronized block
+ if (sync) {
+ final NodeId sender = ad.sender();
+ AntiEntropyAdvertisement<K> myAd = createAdvertisement();
+ try {
+ unicastMessage(sender, antiEntropyAdvertisementSubject, myAd);
+ } catch (IOException e) {
+ log.debug(
+ "Failed to send reactive anti-entropy advertisement to {}",
+ sender);
+ }
+ }
+
externalEvents.forEach(this::notifyListeners);
}