diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java index 5a88df80ae6ed..e03fb3b60a54f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java @@ -15,8 +15,8 @@ import org.elasticsearch.test.tasks.MockTaskManagerListener; import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import java.util.function.Predicate; /** * MockTaskManagerListener that records all task registration/unregistration events @@ -55,13 +55,11 @@ public synchronized List> getEvents() { } public synchronized List getRegistrationEvents() { - List events = this.events.stream().filter(Tuple::v1).map(Tuple::v2).toList(); - return Collections.unmodifiableList(events); + return this.events.stream().filter(Tuple::v1).map(Tuple::v2).toList(); } public synchronized List getUnregistrationEvents() { - List events = this.events.stream().filter(event -> event.v1() == false).map(Tuple::v2).toList(); - return Collections.unmodifiableList(events); + return this.events.stream().filter(Predicate.not(Tuple::v1)).map(Tuple::v2).toList(); } public synchronized void reset() { diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptContextInfoSerializingTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptContextInfoSerializingTests.java index 0fb7f966fb017..f2573dc024180 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptContextInfoSerializingTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptContextInfoSerializingTests.java @@ -67,8 +67,8 @@ private static ScriptContextInfo mutate(ScriptContextInfo instance, Set } static Set mutateOne(Collection instances) { - if (instances.size() == 0) { - return Collections.unmodifiableSet(Set.of(randomInstance())); + if (instances.isEmpty()) { + return Set.of(randomInstance()); } ArrayList mutated = new ArrayList<>(instances); int mutateIndex = randomIntBetween(0, instances.size() - 1); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptParameterInfoSerializingTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptParameterInfoSerializingTests.java index cefd1488eddef..906a8ce9e08d2 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptParameterInfoSerializingTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/ScriptParameterInfoSerializingTests.java @@ -54,8 +54,8 @@ private static ParameterInfo mutate(ParameterInfo instance) { } static List mutateOne(List instances) { - if (instances.size() == 0) { - return Collections.unmodifiableList(List.of(randomInstance())); + if (instances.isEmpty()) { + return List.of(randomInstance()); } ArrayList mutated = new ArrayList<>(instances); int mutateIndex = randomIntBetween(0, instances.size() - 1);