From 9d033293fffbbcacdcc65dba8b645eabff1d0103 Mon Sep 17 00:00:00 2001 From: Dmitry Kuleshov Date: Tue, 30 May 2017 11:30:23 +0300 Subject: [PATCH] fixed npe in subscription manager Signed-off-by: Dmitry Kuleshov --- .../che/api/core/notification/RemoteSubscriptionManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/notification/RemoteSubscriptionManager.java b/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/notification/RemoteSubscriptionManager.java index cdb73d4d42..3b61af9a71 100644 --- a/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/notification/RemoteSubscriptionManager.java +++ b/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/notification/RemoteSubscriptionManager.java @@ -22,13 +22,14 @@ import java.util.HashSet; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiPredicate; import static java.util.Collections.emptySet; @Singleton public class RemoteSubscriptionManager { - private final Map> subscriptionContexts = new HashMap<>(); + private final Map> subscriptionContexts = new ConcurrentHashMap<>(); private final EventService eventService; private final RequestTransmitter requestTransmitter; @@ -56,7 +57,7 @@ public class RemoteSubscriptionManager { } public void register(String method, Class eventType, BiPredicate> biPredicate) { - eventService.subscribe(event -> subscriptionContexts.get(method) + eventService.subscribe(event -> subscriptionContexts.getOrDefault(method, new HashSet<>()) .stream() .filter(context -> biPredicate.test(event, context.scope)) .forEach(context -> transmit(context.endpointId, method, event)),