diff --git a/ipaacalib/java/src/ipaaca/util/ComponentNotifier.java b/ipaacalib/java/src/ipaaca/util/ComponentNotifier.java index c3f16a3bcad7127a566f730ea68831c052ad0c8c..52552f596b7e331c4cf9bb1d00606f44af6ed9ab 100644 --- a/ipaacalib/java/src/ipaaca/util/ComponentNotifier.java +++ b/ipaacalib/java/src/ipaaca/util/ComponentNotifier.java @@ -9,6 +9,7 @@ import ipaaca.LocalMessageIU; import ipaaca.OutputBuffer; import java.util.ArrayList; +import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.List; @@ -39,7 +40,7 @@ public class ComponentNotifier private final ImmutableSet<String> sendCategories; private final ImmutableSet<String> receiveCategories; private final InputBuffer inBuffer; - private List<HandlerFunctor> handlers = new ArrayList<HandlerFunctor>(); + private List<HandlerFunctor> handlers = Collections.synchronizedList(new ArrayList<HandlerFunctor>()); private volatile boolean isInitialized = false; private final BlockingQueue<String> receiverQueue = new LinkedBlockingQueue<>(); @@ -51,9 +52,12 @@ public class ComponentNotifier if(iu.getPayload().get(NAME).equals(componentName))return; //don't re-notify self String receivers[] = iu.getPayload().get(RECEIVE_CATEGORIES).split("\\s*,\\s*"); receiverQueue.addAll(ImmutableSet.copyOf(receivers)); - for (HandlerFunctor h : handlers) + synchronized(handlers) { - h.handle(iu, type, local); + for (HandlerFunctor h : handlers) + { + h.handle(iu, type, local); + } } if (iu.getPayload().get(STATE).equals("new")) { diff --git a/ipaacalib/python/src/ipaaca.py b/ipaacalib/python/src/ipaaca.py index f6f80ad68d273b92d29cb97b23e67d83becbae05..ff81ea802f030be505f87c5b07e98ff63cdf75ce 100755 --- a/ipaacalib/python/src/ipaaca.py +++ b/ipaacalib/python/src/ipaaca.py @@ -1086,7 +1086,7 @@ class Buffer(object): for_event_types -- a list of event types or None if handler should be called for all event types for_categories -- a list of category names or None if handler should - be called for all categoires + be called for all categories """ handler = IUEventHandler(handler_function=handler_function, for_event_types=for_event_types, for_categories=for_categories)