From c4091fbea0ebbdbfb8b10914fc83d9c8e1010dc8 Mon Sep 17 00:00:00 2001 From: Pooya Salehi Date: Mon, 3 Apr 2023 17:30:08 +0200 Subject: [PATCH] Return a copy of messages in MockMTAppender (#94982) Couldn't reproduce the failure, but in principle there is an issue there. Other options are a CopyOnWriteArrayList or just synchronizing on `messages()` return value. Returning a copy should be enough, since this is only used in one place for asserting some test expectations in an `assertBusy`. Closes https://github.com/elastic/elasticsearch/issues/94559 --- .../org/elasticsearch/index/engine/InternalEngineTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 5200388af8881..5c4cdadbfecf4 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -2546,7 +2546,7 @@ private static class MockMTAppender extends AbstractAppender { private final List messages = Collections.synchronizedList(new ArrayList<>()); List messages() { - return messages; + return List.copyOf(messages); } MockMTAppender(final String name) throws IllegalAccessException {