Skip to content
Snippets Groups Projects
Commit aba0771e authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Fix concurrent access to static map, in ChangeService

parent 5b48ca03
No related branches found
No related tags found
No related merge requests found
Pipeline #3278 passed
......@@ -52,6 +52,7 @@ import org.elasticsearch.indices.IndicesService;
import org.joda.time.DateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class ChangeService {
......@@ -65,10 +66,10 @@ public class ChangeService {
private final ESLogger log = Loggers.getLogger(ChangeService.class);
private static final Map<String, ChangeListener> LISTENERS = new HashMap<>();
private static final Map<String, ChangeListener> LISTENERS = new ConcurrentHashMap<>();
private static Map<String, ChangeSource> LISTENERS_SOURCES = new HashMap<>();
private static Map<String, Integer> LISTENERS_SOURCES_USAGE_COUNT = new HashMap<>();
private static Map<String, ChangeSource> LISTENERS_SOURCES = new ConcurrentHashMap<>();
private static Map<String, Integer> LISTENERS_SOURCES_USAGE_COUNT = new ConcurrentHashMap<>();
@Inject
public ChangeService(final Settings settings, IndicesService indicesService) {
......
......@@ -59,6 +59,7 @@ import org.elasticsearch.search.sort.SortOrder;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
......@@ -76,7 +77,7 @@ public class UserEventService extends AbstractService implements ChangeService.C
public static final String INDEX = "user";
public static final String EVENT_TYPE = "event";
private static final Map<String, UserEventListener> LISTENERS = new HashMap<>();
private static final Map<String, UserEventListener> LISTENERS = new ConcurrentHashMap<>();
private static final List<ChangeSource> CHANGE_LISTEN_SOURCES = ImmutableList.of(new ChangeSource(INDEX, EVENT_TYPE));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment