BUG-1120: promote synchronization to all entrypoints
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / NotificationListenerMap.java
index d3039fede8d44ae8c504c555fc4012e18acceee1..2fab0abc9f5b63fce4a0be1b673e3a6de774ce4f 100644 (file)
@@ -19,11 +19,10 @@ import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
 
 final class NotificationListenerMap {
     private final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> listeners =
 
 final class NotificationListenerMap {
     private final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> listeners =
-            Multimaps.synchronizedSetMultimap(HashMultimap.<Class<? extends Notification>, NotificationListenerRegistration<?>>create());
+            HashMultimap.create();
 
     private static Iterable<Class<?>> getNotificationTypes(final Notification notification) {
         final Class<?>[] ifaces = notification.getClass().getInterfaces();
 
     private static Iterable<Class<?>> getNotificationTypes(final Notification notification) {
         final Class<?>[] ifaces = notification.getClass().getInterfaces();
@@ -38,7 +37,7 @@ final class NotificationListenerMap {
         });
     }
 
         });
     }
 
-    Iterable<NotificationListenerRegistration<?>> listenersFor(final Notification notification) {
+    synchronized Iterable<NotificationListenerRegistration<?>> listenersFor(final Notification notification) {
         final Set<NotificationListenerRegistration<?>> toNotify = new HashSet<>();
 
         for (final Class<?> type : getNotificationTypes(notification)) {
         final Set<NotificationListenerRegistration<?>> toNotify = new HashSet<>();
 
         for (final Class<?> type : getNotificationTypes(notification)) {
@@ -51,20 +50,19 @@ final class NotificationListenerMap {
         return toNotify;
     }
 
         return toNotify;
     }
 
-    Iterable<Class<? extends Notification>> getKnownTypes() {
+    synchronized Iterable<Class<? extends Notification>> getKnownTypes() {
         return ImmutableList.copyOf(listeners.keySet());
     }
 
         return ImmutableList.copyOf(listeners.keySet());
     }
 
-    void addRegistrations(final NotificationListenerRegistration<?>... registrations) {
+    synchronized void addRegistrations(final NotificationListenerRegistration<?>... registrations) {
         for (NotificationListenerRegistration<?> reg : registrations) {
             listeners.put(reg.getType(), reg);
         }
     }
 
         for (NotificationListenerRegistration<?> reg : registrations) {
             listeners.put(reg.getType(), reg);
         }
     }
 
-    void removeRegistrations(final NotificationListenerRegistration<?>... registrations) {
+    synchronized void removeRegistrations(final NotificationListenerRegistration<?>... registrations) {
         for (NotificationListenerRegistration<?> reg : registrations) {
             listeners.remove(reg.getType(), reg);
         }
     }
         for (NotificationListenerRegistration<?> reg : registrations) {
             listeners.remove(reg.getType(), reg);
         }
     }
-
 }
 }