From 2509de520f7d1e3187995482ee2ded0cf16050ad Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Mon, 2 Dec 2024 15:21:37 -0800 Subject: [PATCH] Avoid race condition when listeners are registered concurrently --- .../test/cluster/util/resource/MutableResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/MutableResource.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/MutableResource.java index 60863c4ad61db..477ad82e5944a 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/MutableResource.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/MutableResource.java @@ -47,7 +47,7 @@ public void update(Resource delegate) { * * @param listener action to be called on update */ - public void addUpdateListener(Consumer listener) { + public synchronized void addUpdateListener(Consumer listener) { listeners.add(listener); } }