From c44be3b0dd23c2543a65d00bd24e1ef316c0d6a2 Mon Sep 17 00:00:00 2001 From: Colm O hEigeartaigh Date: Tue, 10 Mar 2020 16:12:59 +0000 Subject: [PATCH] AMQ-7440 - Fix potential race condition in DiscoveryRegistryServlet --- .../transport/discovery/http/DiscoveryRegistryServlet.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/discovery/http/DiscoveryRegistryServlet.java b/activemq-http/src/main/java/org/apache/activemq/transport/discovery/http/DiscoveryRegistryServlet.java index 9b519d04b7..ebfb7ae786 100644 --- a/activemq-http/src/main/java/org/apache/activemq/transport/discovery/http/DiscoveryRegistryServlet.java +++ b/activemq-http/src/main/java/org/apache/activemq/transport/discovery/http/DiscoveryRegistryServlet.java @@ -49,12 +49,7 @@ public class DiscoveryRegistryServlet extends HttpServlet { } private ConcurrentMap getServiceGroup(String group) { - ConcurrentMap rc = serviceGroups.get(group); - if( rc == null ) { - rc = new ConcurrentHashMap(); - serviceGroups.put(group, rc); - } - return rc; + return serviceGroups.computeIfAbsent(group, k -> new ConcurrentHashMap()); } @Override