replace .collect(toUnmodifiableList()) with .toList() (#84760)

Replace collect with a simipler toList call that also creates immutable
collection.
This commit is contained in:
Ievgen Degtiarenko 2022-03-10 10:27:46 +01:00 committed by GitHub
parent 83d0e8e923
commit 01c5bc04e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 90 additions and 194 deletions

View file

@ -98,7 +98,7 @@ class JvmOption {
Stream.of("-Xshare:off"), Stream.of("-Xshare:off"),
Stream.of("-XX:+PrintFlagsFinal"), Stream.of("-XX:+PrintFlagsFinal"),
Stream.of("-version") Stream.of("-version")
).reduce(Stream::concat).get().collect(Collectors.toUnmodifiableList()); ).reduce(Stream::concat).get().toList();
final Process process = new ProcessBuilder().command(command).start(); final Process process = new ProcessBuilder().command(command).start();
final List<String> output = readLinesFromInputStream(process.getInputStream()); final List<String> output = readLinesFromInputStream(process.getInputStream());
final List<String> error = readLinesFromInputStream(process.getErrorStream()); final List<String> error = readLinesFromInputStream(process.getErrorStream());
@ -119,7 +119,7 @@ class JvmOption {
private static List<String> readLinesFromInputStream(final InputStream is) throws IOException { private static List<String> readLinesFromInputStream(final InputStream is) throws IOException {
try (InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr)) { try (InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr)) {
return br.lines().collect(Collectors.toUnmodifiableList()); return br.lines().toList();
} }
} }
} }

View file

@ -125,9 +125,7 @@ final class JvmOptionsParser {
final List<String> jvmOptions = readJvmOptionsFiles(config); final List<String> jvmOptions = readJvmOptionsFiles(config);
if (esJavaOpts != null) { if (esJavaOpts != null) {
jvmOptions.addAll( jvmOptions.addAll(Arrays.stream(esJavaOpts.split("\\s+")).filter(Predicate.not(String::isBlank)).toList());
Arrays.stream(esJavaOpts.split("\\s+")).filter(Predicate.not(String::isBlank)).collect(Collectors.toUnmodifiableList())
);
} }
final List<String> substitutedJvmOptions = substitutePlaceholders(jvmOptions, Collections.unmodifiableMap(substitutions)); final List<String> substitutedJvmOptions = substitutePlaceholders(jvmOptions, Collections.unmodifiableMap(substitutions));

View file

@ -63,10 +63,7 @@ public class CompositeTrustConfig implements SslTrustConfig {
@Override @Override
public Collection<? extends StoredCertificate> getConfiguredCertificates() { public Collection<? extends StoredCertificate> getConfiguredCertificates() {
return configs.stream() return configs.stream().map(SslTrustConfig::getConfiguredCertificates).flatMap(Collection::stream).toList();
.map(SslTrustConfig::getConfiguredCertificates)
.flatMap(Collection::stream)
.collect(Collectors.toUnmodifiableList());
} }
@Override @Override

View file

@ -28,7 +28,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManager;
@ -281,10 +280,7 @@ public final class KeyStoreUtil {
if (certificates == null || certificates.length == 0) { if (certificates == null || certificates.length == 0) {
return List.of(); return List.of();
} }
return Stream.of(certificates) return Stream.of(certificates).filter(c -> c instanceof X509Certificate).map(X509Certificate.class::cast).toList();
.filter(c -> c instanceof X509Certificate)
.map(X509Certificate.class::cast)
.collect(Collectors.toUnmodifiableList());
} catch (KeyStoreException e) { } catch (KeyStoreException e) {
throw exceptionHandler.apply(e); throw exceptionHandler.apply(e);
} }

View file

@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509ExtendedTrustManager; import javax.net.ssl.X509ExtendedTrustManager;
@ -87,7 +86,7 @@ public final class PemTrustConfig implements SslTrustConfig {
} }
private List<Path> resolveFiles() { private List<Path> resolveFiles() {
return this.certificateAuthorities.stream().map(this::resolveFile).collect(Collectors.toUnmodifiableList()); return this.certificateAuthorities.stream().map(this::resolveFile).toList();
} }
private Path resolveFile(String other) { private Path resolveFile(String other) {

View file

@ -27,7 +27,6 @@ import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
@ -121,7 +120,7 @@ public class StoreKeyConfig implements SslKeyConfig {
return null; return null;
}) })
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList()); .toList();
} }
@Override @Override
@ -136,7 +135,7 @@ public class StoreKeyConfig implements SslKeyConfig {
firstElement = false; firstElement = false;
} }
return certificates.stream(); return certificates.stream();
}).collect(Collectors.toUnmodifiableList()); }).toList();
} }
@Override @Override

View file

@ -19,7 +19,6 @@ import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import javax.net.ssl.X509ExtendedTrustManager; import javax.net.ssl.X509ExtendedTrustManager;
@ -73,7 +72,7 @@ public final class StoreTrustConfig implements SslTrustConfig {
} else { } else {
return null; return null;
} }
}).filter(Objects::nonNull).collect(Collectors.toUnmodifiableList()); }).filter(Objects::nonNull).toList();
} }
@Override @Override

View file

@ -12,18 +12,13 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.contains;
public class KibanaPluginTests extends ESTestCase { public class KibanaPluginTests extends ESTestCase {
public void testKibanaIndexNames() { public void testKibanaIndexNames() {
assertThat( assertThat(
new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY) new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY).stream().map(SystemIndexDescriptor::getIndexPattern).toList(),
.stream()
.map(SystemIndexDescriptor::getIndexPattern)
.collect(Collectors.toUnmodifiableList()),
contains(".kibana_*", ".reporting-*", ".apm-agent-configuration*", ".apm-custom-link*") contains(".kibana_*", ".reporting-*", ".apm-agent-configuration*", ".apm-custom-link*")
); );
} }

View file

@ -20,7 +20,6 @@ import org.elasticsearch.search.aggregations.InternalAggregations;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
/** /**
@ -171,12 +170,10 @@ public abstract class SearchProgressListener {
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(SearchPhaseResult::getSearchShardTarget) .map(SearchPhaseResult::getSearchShardTarget)
.map(e -> new SearchShard(e.getClusterAlias(), e.getShardId())) .map(e -> new SearchShard(e.getClusterAlias(), e.getShardId()))
.collect(Collectors.toUnmodifiableList()); .toList();
} }
static List<SearchShard> buildSearchShards(GroupShardsIterator<SearchShardIterator> its) { static List<SearchShard> buildSearchShards(GroupShardsIterator<SearchShardIterator> its) {
return StreamSupport.stream(its.spliterator(), false) return StreamSupport.stream(its.spliterator(), false).map(e -> new SearchShard(e.getClusterAlias(), e.shardId())).toList();
.map(e -> new SearchShard(e.getClusterAlias(), e.shardId()))
.collect(Collectors.toUnmodifiableList());
} }
} }

View file

@ -275,7 +275,7 @@ public class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole> {
static { static {
final List<Field> roleFields = Arrays.stream(DiscoveryNodeRole.class.getFields()) final List<Field> roleFields = Arrays.stream(DiscoveryNodeRole.class.getFields())
.filter(f -> f.getType().equals(DiscoveryNodeRole.class)) .filter(f -> f.getType().equals(DiscoveryNodeRole.class))
.collect(Collectors.toUnmodifiableList()); .toList();
// this will detect duplicate role names // this will detect duplicate role names
final Map<String, DiscoveryNodeRole> roleMap = roleFields.stream().map(f -> { final Map<String, DiscoveryNodeRole> roleMap = roleFields.stream().map(f -> {
try { try {

View file

@ -562,10 +562,7 @@ public class ReplicationTracker extends AbstractIndexShardComponent implements L
* Returns a list of peer recovery retention leases installed in this replication group * Returns a list of peer recovery retention leases installed in this replication group
*/ */
public List<RetentionLease> getPeerRecoveryRetentionLeases() { public List<RetentionLease> getPeerRecoveryRetentionLeases() {
return getRetentionLeases().leases() return getRetentionLeases().leases().stream().filter(lease -> PEER_RECOVERY_RETENTION_LEASE_SOURCE.equals(lease.source())).toList();
.stream()
.filter(lease -> PEER_RECOVERY_RETENTION_LEASE_SOURCE.equals(lease.source()))
.collect(Collectors.toUnmodifiableList());
} }
/** /**

View file

@ -15,7 +15,6 @@ import org.elasticsearch.cluster.metadata.Metadata;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* An "associated index" is an index that is related to or derived from a system * An "associated index" is an index that is related to or derived from a system
@ -106,7 +105,7 @@ public class AssociatedIndexDescriptor implements IndexPatternMatcher {
*/ */
@Override @Override
public List<String> getMatchingIndices(Metadata metadata) { public List<String> getMatchingIndices(Metadata metadata) {
return metadata.indices().keySet().stream().filter(this::matchesIndexPattern).collect(Collectors.toUnmodifiableList()); return metadata.indices().keySet().stream().filter(this::matchesIndexPattern).toList();
} }
/** /**

View file

@ -17,7 +17,6 @@ import org.elasticsearch.cluster.metadata.Metadata;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import static org.elasticsearch.indices.AssociatedIndexDescriptor.buildAutomaton; import static org.elasticsearch.indices.AssociatedIndexDescriptor.buildAutomaton;
@ -91,7 +90,7 @@ public class SystemDataStreamDescriptor {
* @return List of names of backing indices * @return List of names of backing indices
*/ */
public List<String> getBackingIndexNames(Metadata metadata) { public List<String> getBackingIndexNames(Metadata metadata) {
return metadata.indices().keySet().stream().filter(this.characterRunAutomaton::run).collect(Collectors.toUnmodifiableList()); return metadata.indices().keySet().stream().filter(this.characterRunAutomaton::run).toList();
} }
public String getDescription() { public String getDescription() {

View file

@ -31,7 +31,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* A system index descriptor describes one or more system indices. It can match a number of indices using * A system index descriptor describes one or more system indices. It can match a number of indices using
@ -400,7 +399,7 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable<Sy
*/ */
@Override @Override
public List<String> getMatchingIndices(Metadata metadata) { public List<String> getMatchingIndices(Metadata metadata) {
return metadata.indices().keySet().stream().filter(this::matchesIndexPattern).collect(Collectors.toUnmodifiableList()); return metadata.indices().keySet().stream().filter(this::matchesIndexPattern).toList();
} }
/** /**

View file

@ -50,7 +50,6 @@ import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.elasticsearch.tasks.TaskResultsService.TASKS_DESCRIPTOR; import static org.elasticsearch.tasks.TaskResultsService.TASKS_DESCRIPTOR;
import static org.elasticsearch.tasks.TaskResultsService.TASKS_FEATURE_NAME; import static org.elasticsearch.tasks.TaskResultsService.TASKS_FEATURE_NAME;
@ -513,7 +512,7 @@ public class SystemIndices {
.stream() .stream()
.flatMap(entry -> entry.getValue().getIndexDescriptors().stream().map(descriptor -> new Tuple<>(entry.getKey(), descriptor))) .flatMap(entry -> entry.getValue().getIndexDescriptors().stream().map(descriptor -> new Tuple<>(entry.getKey(), descriptor)))
.sorted(Comparator.comparing(d -> d.v1() + ":" + d.v2().getIndexPattern())) // Consistent ordering -> consistent error message .sorted(Comparator.comparing(d -> d.v1() + ":" + d.v2().getIndexPattern())) // Consistent ordering -> consistent error message
.collect(Collectors.toUnmodifiableList()); .toList();
List<Tuple<String, SystemDataStreamDescriptor>> sourceDataStreamDescriptorPair = sourceToFeature.entrySet() List<Tuple<String, SystemDataStreamDescriptor>> sourceDataStreamDescriptorPair = sourceToFeature.entrySet()
.stream() .stream()
.filter(entry -> entry.getValue().getDataStreamDescriptors().isEmpty() == false) .filter(entry -> entry.getValue().getDataStreamDescriptors().isEmpty() == false)
@ -521,7 +520,7 @@ public class SystemIndices {
entry -> entry.getValue().getDataStreamDescriptors().stream().map(descriptor -> new Tuple<>(entry.getKey(), descriptor)) entry -> entry.getValue().getDataStreamDescriptors().stream().map(descriptor -> new Tuple<>(entry.getKey(), descriptor))
) )
.sorted(Comparator.comparing(d -> d.v1() + ":" + d.v2().getDataStreamName())) // Consistent ordering -> consistent error message .sorted(Comparator.comparing(d -> d.v1() + ":" + d.v2().getDataStreamName())) // Consistent ordering -> consistent error message
.collect(Collectors.toUnmodifiableList()); .toList();
// This is O(n^2) with the number of system index descriptors, and each check is quadratic with the number of states in the // This is O(n^2) with the number of system index descriptors, and each check is quadratic with the number of states in the
// automaton, but the absolute number of system index descriptors should be quite small (~10s at most), and the number of states // automaton, but the absolute number of system index descriptors should be quite small (~10s at most), and the number of states
@ -533,7 +532,7 @@ public class SystemIndices {
d -> overlaps(descriptorToCheck.v2(), d.v2()) d -> overlaps(descriptorToCheck.v2(), d.v2())
|| (d.v2().getAliasName() != null && descriptorToCheck.v2().matchesIndexPattern(d.v2().getAliasName())) || (d.v2().getAliasName() != null && descriptorToCheck.v2().matchesIndexPattern(d.v2().getAliasName()))
) )
.collect(toUnmodifiableList()); .toList();
if (descriptorsMatchingThisPattern.isEmpty() == false) { if (descriptorsMatchingThisPattern.isEmpty() == false) {
throw new IllegalStateException( throw new IllegalStateException(
"a system index descriptor [" "a system index descriptor ["
@ -552,7 +551,7 @@ public class SystemIndices {
dsTuple -> descriptorToCheck.v2().matchesIndexPattern(dsTuple.v2().getDataStreamName()) dsTuple -> descriptorToCheck.v2().matchesIndexPattern(dsTuple.v2().getDataStreamName())
|| overlaps(descriptorToCheck.v2().getIndexPattern(), dsTuple.v2().getBackingIndexPattern()) || overlaps(descriptorToCheck.v2().getIndexPattern(), dsTuple.v2().getBackingIndexPattern())
) )
.collect(toUnmodifiableList()); .toList();
if (dataStreamsMatching.isEmpty() == false) { if (dataStreamsMatching.isEmpty() == false) {
throw new IllegalStateException( throw new IllegalStateException(
"a system index descriptor [" "a system index descriptor ["

View file

@ -404,7 +404,7 @@ public class TaskManager implements ClusterStateApplier {
ban.registerChannel(DIRECT_CHANNEL_TRACKER); ban.registerChannel(DIRECT_CHANNEL_TRACKER);
} }
} }
return cancellableTasks.getByParent(parentTaskId).map(t -> t.task).collect(Collectors.toUnmodifiableList()); return cancellableTasks.getByParent(parentTaskId).map(t -> t.task).toList();
} }
/** /**

View file

@ -52,7 +52,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
@ -445,7 +444,7 @@ public class TimeSeriesMetrics {
for (TimeSeriesMetricSelector selector : selectors) { for (TimeSeriesMetricSelector selector : selectors) {
metrics = metrics.filter(selector.asPredicate()); metrics = metrics.filter(selector.asPredicate());
} }
return metrics.collect(Collectors.toUnmodifiableList()); return metrics.toList();
} }
private SearchRequest searchInRange(List<String> metrics, List<TimeSeriesDimensionSelector> dimensions, long from, long to, int size) { private SearchRequest searchInRange(List<String> metrics, List<TimeSeriesDimensionSelector> dimensions, long from, long to, int size) {

View file

@ -48,10 +48,7 @@ public class MapsTests extends ESTestCase {
final String key = randomValueOtherThanMany(keys::contains, () -> randomAlphaOfLength(16)); final String key = randomValueOtherThanMany(keys::contains, () -> randomAlphaOfLength(16));
final String value = randomAlphaOfLength(16); final String value = randomAlphaOfLength(16);
final Map<String, String> concatenation = Maps.copyMapWithAddedEntry(map, key, value); final Map<String, String> concatenation = Maps.copyMapWithAddedEntry(map, key, value);
assertMapEntriesAndImmutability( assertMapEntriesAndImmutability(concatenation, Stream.concat(entries.stream(), Stream.of(entry(key, value))).toList());
concatenation,
Stream.concat(entries.stream(), Stream.of(entry(key, value))).collect(Collectors.toUnmodifiableList())
);
} }
public void testAddEntryInImmutableMap() { public void testAddEntryInImmutableMap() {
@ -67,10 +64,7 @@ public class MapsTests extends ESTestCase {
final String key = randomValueOtherThanMany(keys::contains, () -> randomAlphaOfLength(16)); final String key = randomValueOtherThanMany(keys::contains, () -> randomAlphaOfLength(16));
final String value = randomAlphaOfLength(16); final String value = randomAlphaOfLength(16);
final Map<String, String> add = Maps.copyMapWithAddedOrReplacedEntry(map, key, value); final Map<String, String> add = Maps.copyMapWithAddedOrReplacedEntry(map, key, value);
assertMapEntriesAndImmutability( assertMapEntriesAndImmutability(add, Stream.concat(entries.stream(), Stream.of(entry(key, value))).toList());
add,
Stream.concat(entries.stream(), Stream.of(entry(key, value))).collect(Collectors.toUnmodifiableList())
);
} }
public void testReplaceEntryInImmutableMap() { public void testReplaceEntryInImmutableMap() {
@ -88,8 +82,7 @@ public class MapsTests extends ESTestCase {
final Map<String, String> replaced = Maps.copyMapWithAddedOrReplacedEntry(map, key, value); final Map<String, String> replaced = Maps.copyMapWithAddedOrReplacedEntry(map, key, value);
assertMapEntriesAndImmutability( assertMapEntriesAndImmutability(
replaced, replaced,
Stream.concat(entries.stream().filter(e -> key.equals(e.getKey()) == false), Stream.of(entry(key, value))) Stream.concat(entries.stream().filter(e -> key.equals(e.getKey()) == false), Stream.of(entry(key, value))).toList()
.collect(Collectors.toUnmodifiableList())
); );
} }

View file

@ -15,7 +15,6 @@ import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -84,7 +83,7 @@ public class IterablesTests extends ESTestCase {
final List<String> list = Stream.generate(() -> randomAlphaOfLengthBetween(3, 9)) final List<String> list = Stream.generate(() -> randomAlphaOfLengthBetween(3, 9))
.limit(randomIntBetween(10, 30)) .limit(randomIntBetween(10, 30))
.distinct() .distinct()
.collect(Collectors.toUnmodifiableList()); .toList();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
final String val = list.get(i); final String val = list.get(i);
assertThat(Iterables.indexOf(list, val::equals), is(i)); assertThat(Iterables.indexOf(list, val::equals), is(i));

View file

@ -284,13 +284,9 @@ public abstract class ESTestCase extends LuceneTestCase {
.filter(unsupportedTZIdsPredicate.negate()) .filter(unsupportedTZIdsPredicate.negate())
.filter(unsupportedZoneIdsPredicate.negate()) .filter(unsupportedZoneIdsPredicate.negate())
.sorted() .sorted()
.collect(Collectors.toUnmodifiableList()); .toList();
JAVA_ZONE_IDS = ZoneId.getAvailableZoneIds() JAVA_ZONE_IDS = ZoneId.getAvailableZoneIds().stream().filter(unsupportedZoneIdsPredicate.negate()).sorted().toList();
.stream()
.filter(unsupportedZoneIdsPredicate.negate())
.sorted()
.collect(Collectors.toUnmodifiableList());
} }
@SuppressForbidden(reason = "force log4j and netty sysprops") @SuppressForbidden(reason = "force log4j and netty sysprops")

View file

@ -38,10 +38,7 @@ public class NodeRoles {
public static Settings onlyRoles(final Settings settings, final Set<DiscoveryNodeRole> roles) { public static Settings onlyRoles(final Settings settings, final Set<DiscoveryNodeRole> roles) {
return Settings.builder() return Settings.builder()
.put(settings) .put(settings)
.putList( .putList(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), roles.stream().map(DiscoveryNodeRole::roleName).toList())
NodeRoleSettings.NODE_ROLES_SETTING.getKey(),
roles.stream().map(DiscoveryNodeRole::roleName).collect(Collectors.toUnmodifiableList())
)
.build(); .build();
} }
@ -57,7 +54,7 @@ public class NodeRoles {
.stream() .stream()
.filter(Predicate.not(roles::contains)) .filter(Predicate.not(roles::contains))
.map(DiscoveryNodeRole::roleName) .map(DiscoveryNodeRole::roleName)
.collect(Collectors.toUnmodifiableList()) .toList()
); );
return builder.build(); return builder.build();
} }
@ -73,7 +70,7 @@ public class NodeRoles {
Stream.concat(NodeRoleSettings.NODE_ROLES_SETTING.get(settings).stream(), roles.stream()) Stream.concat(NodeRoleSettings.NODE_ROLES_SETTING.get(settings).stream(), roles.stream())
.map(DiscoveryNodeRole::roleName) .map(DiscoveryNodeRole::roleName)
.distinct() .distinct()
.collect(Collectors.toUnmodifiableList()) .toList()
); );
return builder.build(); return builder.build();
} }

View file

@ -904,9 +904,7 @@ public abstract class ESRestTestCase extends ESTestCase {
Request getShutdownStatus = new Request("GET", "_nodes/shutdown"); Request getShutdownStatus = new Request("GET", "_nodes/shutdown");
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus)); Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes"); List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
List<String> nodeIds = nodesArray.stream() List<String> nodeIds = nodesArray.stream().map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id")).toList();
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))
.collect(Collectors.toUnmodifiableList());
for (String nodeId : nodeIds) { for (String nodeId : nodeIds) {
Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown"); Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown");
assertOK(adminClient().performRequest(deleteRequest)); assertOK(adminClient().performRequest(deleteRequest));

View file

@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class AutoscalingCountTestDeciderService implements AutoscalingDeciderService { public class AutoscalingCountTestDeciderService implements AutoscalingDeciderService {
@ -46,7 +45,7 @@ public class AutoscalingCountTestDeciderService implements AutoscalingDeciderSer
@Override @Override
public List<DiscoveryNodeRole> roles() { public List<DiscoveryNodeRole> roles() {
return DiscoveryNodeRole.roles().stream().collect(Collectors.toUnmodifiableList()); return DiscoveryNodeRole.roles().stream().toList();
} }
@Override @Override

View file

@ -18,7 +18,6 @@ import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderService;
import java.util.List; import java.util.List;
import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier; import java.util.concurrent.CyclicBarrier;
import java.util.stream.Collectors;
public class AutoscalingSyncTestDeciderService implements AutoscalingDeciderService { public class AutoscalingSyncTestDeciderService implements AutoscalingDeciderService {
@ -62,7 +61,7 @@ public class AutoscalingSyncTestDeciderService implements AutoscalingDeciderServ
@Override @Override
public List<DiscoveryNodeRole> roles() { public List<DiscoveryNodeRole> roles() {
return DiscoveryNodeRole.roles().stream().collect(Collectors.toUnmodifiableList()); return DiscoveryNodeRole.roles().stream().toList();
} }
@Override @Override

View file

@ -19,7 +19,6 @@ import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
public class FixedAutoscalingDeciderService implements AutoscalingDeciderService { public class FixedAutoscalingDeciderService implements AutoscalingDeciderService {
@ -72,7 +71,7 @@ public class FixedAutoscalingDeciderService implements AutoscalingDeciderService
@Override @Override
public List<DiscoveryNodeRole> roles() { public List<DiscoveryNodeRole> roles() {
return DiscoveryNodeRole.roles().stream().collect(Collectors.toUnmodifiableList()); return DiscoveryNodeRole.roles().stream().toList();
} }
@Override @Override

View file

@ -50,7 +50,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ -504,7 +503,7 @@ public class AutoFollowIT extends CcrIntegTestCase {
final String pattern = prefix + "pattern"; final String pattern = prefix + "pattern";
putAutoFollowPatterns(pattern, new String[] { prefix + "*" }); putAutoFollowPatterns(pattern, new String[] { prefix + "*" });
return pattern; return pattern;
}).collect(toUnmodifiableList()); }).toList();
// pick up some random pattern to pause // pick up some random pattern to pause
final List<String> pausedAutoFollowerPatterns = randomSubsetOf(randomIntBetween(1, 3), autoFollowPatterns); final List<String> pausedAutoFollowerPatterns = randomSubsetOf(randomIntBetween(1, 3), autoFollowPatterns);

View file

@ -76,7 +76,7 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
public static final Setting<List<License.LicenseType>> ALLOWED_LICENSE_TYPES_SETTING = Setting.listSetting( public static final Setting<List<License.LicenseType>> ALLOWED_LICENSE_TYPES_SETTING = Setting.listSetting(
"xpack.license.upload.types", "xpack.license.upload.types",
ALLOWABLE_UPLOAD_TYPES.stream().map(License.LicenseType::getTypeName).collect(Collectors.toUnmodifiableList()), ALLOWABLE_UPLOAD_TYPES.stream().map(License.LicenseType::getTypeName).toList(),
License.LicenseType::parse, License.LicenseType::parse,
LicenseService::validateUploadTypesSetting, LicenseService::validateUploadTypesSetting,
Setting.Property.NodeScope Setting.Property.NodeScope
@ -642,7 +642,7 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
} }
private static List<License.LicenseType> getAllowableUploadTypes() { private static List<License.LicenseType> getAllowableUploadTypes() {
return Stream.of(License.LicenseType.values()).filter(t -> t != License.LicenseType.BASIC).collect(Collectors.toUnmodifiableList()); return Stream.of(License.LicenseType.values()).filter(t -> t != License.LicenseType.BASIC).toList();
} }
private static void validateUploadTypesSetting(List<License.LicenseType> value) { private static void validateUploadTypesSetting(List<License.LicenseType> value) {

View file

@ -14,7 +14,6 @@ import org.elasticsearch.xpack.core.XPackFeatureSet;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
public class XPackUsageResponse extends ActionResponse { public class XPackUsageResponse extends ActionResponse {
@ -37,7 +36,7 @@ public class XPackUsageResponse extends ActionResponse {
// we can only write the usages with version the coordinating node is compatible with otherwise it will not know the named writeable // we can only write the usages with version the coordinating node is compatible with otherwise it will not know the named writeable
final List<XPackFeatureSet.Usage> usagesToWrite = usages.stream() final List<XPackFeatureSet.Usage> usagesToWrite = usages.stream()
.filter(usage -> out.getVersion().onOrAfter(usage.getMinimalSupportedVersion())) .filter(usage -> out.getVersion().onOrAfter(usage.getMinimalSupportedVersion()))
.collect(Collectors.toUnmodifiableList()); .toList();
writeTo(out, usagesToWrite); writeTo(out, usagesToWrite);
} }

View file

@ -113,7 +113,7 @@ public class ClassificationInferenceResults extends SingleValueInferenceResults
return featureImportances.stream() return featureImportances.stream()
.sorted((l, r) -> Double.compare(r.getTotalImportance(), l.getTotalImportance())) .sorted((l, r) -> Double.compare(r.getTotalImportance(), l.getTotalImportance()))
.limit(numTopFeatures) .limit(numTopFeatures)
.collect(Collectors.toUnmodifiableList()); .toList();
} }
public ClassificationInferenceResults(StreamInput in) throws IOException { public ClassificationInferenceResults(StreamInput in) throws IOException {

View file

@ -69,7 +69,7 @@ public class RegressionInferenceResults extends SingleValueInferenceResults {
return featureImportances.stream() return featureImportances.stream()
.sorted((l, r) -> Double.compare(Math.abs(r.getImportance()), Math.abs(l.getImportance()))) .sorted((l, r) -> Double.compare(Math.abs(r.getImportance()), Math.abs(l.getImportance())))
.limit(numTopFeatures) .limit(numTopFeatures)
.collect(Collectors.toUnmodifiableList()); .toList();
} }
public RegressionInferenceResults(StreamInput in) throws IOException { public RegressionInferenceResults(StreamInput in) throws IOException {

View file

@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* Unlike index-backed service account tokens, file-backed tokens are local to the node. * Unlike index-backed service account tokens, file-backed tokens are local to the node.
@ -67,8 +66,8 @@ public class GetServiceAccountCredentialsNodesResponse extends BaseNodesResponse
} }
return fileTokenDistribution.entrySet() return fileTokenDistribution.entrySet()
.stream() .stream()
.map(entry -> TokenInfo.fileToken(entry.getKey(), entry.getValue().stream().sorted().collect(Collectors.toUnmodifiableList()))) .map(entry -> TokenInfo.fileToken(entry.getKey(), entry.getValue().stream().sorted().toList()))
.collect(Collectors.toUnmodifiableList()); .toList();
} }
public static class Node extends BaseNodeResponse { public static class Node extends BaseNodeResponse {

View file

@ -18,8 +18,6 @@ import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static java.util.stream.Collectors.toUnmodifiableList;
public class GetServiceAccountCredentialsResponse extends ActionResponse implements ToXContentObject { public class GetServiceAccountCredentialsResponse extends ActionResponse implements ToXContentObject {
private final String principal; private final String principal;
@ -32,7 +30,7 @@ public class GetServiceAccountCredentialsResponse extends ActionResponse impleme
GetServiceAccountCredentialsNodesResponse nodesResponse GetServiceAccountCredentialsNodesResponse nodesResponse
) { ) {
this.principal = principal; this.principal = principal;
this.indexTokenInfos = indexTokenInfos == null ? List.of() : indexTokenInfos.stream().sorted().collect(toUnmodifiableList()); this.indexTokenInfos = indexTokenInfos == null ? List.of() : indexTokenInfos.stream().sorted().toList();
this.nodesResponse = nodesResponse; this.nodesResponse = nodesResponse;
} }

View file

@ -221,7 +221,7 @@ public final class GetUserPrivilegesResponse extends ActionResponse {
builder.startArray(RoleDescriptor.Fields.FIELD_PERMISSIONS.getPreferredName()); builder.startArray(RoleDescriptor.Fields.FIELD_PERMISSIONS.getPreferredName());
final List<FieldPermissionsDefinition.FieldGrantExcludeGroup> sortedFieldSecurity = this.fieldSecurity.stream() final List<FieldPermissionsDefinition.FieldGrantExcludeGroup> sortedFieldSecurity = this.fieldSecurity.stream()
.sorted() .sorted()
.collect(Collectors.toUnmodifiableList()); .toList();
for (FieldPermissionsDefinition.FieldGrantExcludeGroup group : sortedFieldSecurity) { for (FieldPermissionsDefinition.FieldGrantExcludeGroup group : sortedFieldSecurity) {
builder.startObject(); builder.startObject();
if (nonEmpty(group.getGrantedFields())) { if (nonEmpty(group.getGrantedFields())) {

View file

@ -108,11 +108,7 @@ public class IndicesAccessControl {
} }
private List<String> getIndexNames(Predicate<IndexAccessControl> predicate) { private List<String> getIndexNames(Predicate<IndexAccessControl> predicate) {
return indexPermissions.entrySet() return indexPermissions.entrySet().stream().filter(entry -> predicate.test(entry.getValue())).map(Map.Entry::getKey).toList();
.stream()
.filter(entry -> predicate.test(entry.getValue()))
.map(Map.Entry::getKey)
.collect(Collectors.toUnmodifiableList());
} }
public enum DlsFlsUsage { public enum DlsFlsUsage {

View file

@ -36,7 +36,6 @@ import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import static org.apache.lucene.search.BooleanClause.Occur.FILTER; import static org.apache.lucene.search.BooleanClause.Occur.FILTER;
import static org.apache.lucene.search.BooleanClause.Occur.SHOULD; import static org.apache.lucene.search.BooleanClause.Occur.SHOULD;
@ -151,10 +150,10 @@ public final class DocumentPermissions implements CacheKey {
private void evaluateQueries(DlsQueryEvaluationContext context) { private void evaluateQueries(DlsQueryEvaluationContext context) {
if (queries != null && evaluatedQueries == null) { if (queries != null && evaluatedQueries == null) {
evaluatedQueries = queries.stream().map(context::evaluate).collect(Collectors.toUnmodifiableList()); evaluatedQueries = queries.stream().map(context::evaluate).toList();
} }
if (limitedByQueries != null && evaluatedLimitedByQueries == null) { if (limitedByQueries != null && evaluatedLimitedByQueries == null) {
evaluatedLimitedByQueries = limitedByQueries.stream().map(context::evaluate).collect(Collectors.toUnmodifiableList()); evaluatedLimitedByQueries = limitedByQueries.stream().map(context::evaluate).toList();
} }
} }

View file

@ -46,7 +46,6 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.Collectors;
/** /**
* Translates cluster privilege names into concrete implementations * Translates cluster privilege names into concrete implementations
@ -319,7 +318,7 @@ public class ClusterPrivilegeResolver {
.stream() .stream()
.filter(e -> e.getValue().permission().check(action, request, authentication)) .filter(e -> e.getValue().permission().check(action, request, authentication))
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.collect(Collectors.toUnmodifiableList()); .toList();
} }
/** /**

View file

@ -46,7 +46,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors;
import static java.util.Map.entry; import static java.util.Map.entry;
import static org.elasticsearch.xpack.core.security.support.Automatons.patterns; import static org.elasticsearch.xpack.core.security.support.Automatons.patterns;
@ -253,10 +252,6 @@ public final class IndexPrivilege extends Privilege {
* @see Privilege#sortByAccessLevel * @see Privilege#sortByAccessLevel
*/ */
public static Collection<String> findPrivilegesThatGrant(String action) { public static Collection<String> findPrivilegesThatGrant(String action) {
return VALUES.entrySet() return VALUES.entrySet().stream().filter(e -> e.getValue().predicate.test(action)).map(e -> e.getKey()).toList();
.stream()
.filter(e -> e.getValue().predicate.test(action))
.map(e -> e.getKey())
.collect(Collectors.toUnmodifiableList());
} }
} }

View file

@ -516,7 +516,7 @@ public class SSLService {
.filter(e -> e.getValue().equals(configuration)) .filter(e -> e.getValue().equals(configuration))
.limit(2) // we only need to distinguishing between 0/1/many .limit(2) // we only need to distinguishing between 0/1/many
.map(Entry::getKey) .map(Entry::getKey)
.collect(Collectors.toUnmodifiableList()); .toList();
final String name = switch (names.size()) { final String name = switch (names.size()) {
case 0 -> "(unknown)"; case 0 -> "(unknown)";
case 1 -> names.get(0); case 1 -> names.get(0);
@ -637,11 +637,7 @@ public class SSLService {
); );
} }
} else if (settings.hasValue(enabledSetting) == false) { } else if (settings.hasValue(enabledSetting) == false) {
final List<String> sslSettingNames = settings.keySet() final List<String> sslSettingNames = settings.keySet().stream().filter(s -> s.startsWith(prefix)).sorted().toList();
.stream()
.filter(s -> s.startsWith(prefix))
.sorted()
.collect(Collectors.toUnmodifiableList());
if (sslSettingNames.isEmpty() == false) { if (sslSettingNames.isEmpty() == false) {
throw new ElasticsearchSecurityException( throw new ElasticsearchSecurityException(
"invalid configuration for " "invalid configuration for "

View file

@ -41,7 +41,6 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING;
import static org.elasticsearch.discovery.DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE; import static org.elasticsearch.discovery.DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE;
@ -93,7 +92,7 @@ public class LicenseServiceTests extends ESTestCase {
randomIntBetween(1, LicenseService.ALLOWABLE_UPLOAD_TYPES.size() - 1), randomIntBetween(1, LicenseService.ALLOWABLE_UPLOAD_TYPES.size() - 1),
LicenseService.ALLOWABLE_UPLOAD_TYPES LicenseService.ALLOWABLE_UPLOAD_TYPES
); );
final List<String> allowedNames = allowed.stream().map(License.LicenseType::getTypeName).collect(Collectors.toUnmodifiableList()); final List<String> allowedNames = allowed.stream().map(License.LicenseType::getTypeName).toList();
final Settings settings = Settings.builder().putList("xpack.license.upload.types", allowedNames).build(); final Settings settings = Settings.builder().putList("xpack.license.upload.types", allowedNames).build();
assertRegisterValidLicense(settings, randomFrom(allowed)); assertRegisterValidLicense(settings, randomFrom(allowed));
} }
@ -107,7 +106,7 @@ public class LicenseServiceTests extends ESTestCase {
randomIntBetween(1, LicenseService.ALLOWABLE_UPLOAD_TYPES.size() - 2), randomIntBetween(1, LicenseService.ALLOWABLE_UPLOAD_TYPES.size() - 2),
LicenseService.ALLOWABLE_UPLOAD_TYPES LicenseService.ALLOWABLE_UPLOAD_TYPES
); );
final List<String> allowedNames = allowed.stream().map(License.LicenseType::getTypeName).collect(Collectors.toUnmodifiableList()); final List<String> allowedNames = allowed.stream().map(License.LicenseType::getTypeName).toList();
final Settings settings = Settings.builder().putList("xpack.license.upload.types", allowedNames).build(); final Settings settings = Settings.builder().putList("xpack.license.upload.types", allowedNames).build();
final License.LicenseType notAllowed = randomValueOtherThanMany( final License.LicenseType notAllowed = randomValueOtherThanMany(
test -> allowed.contains(test), test -> allowed.contains(test),

View file

@ -694,7 +694,7 @@ public class LocalStateCompositeXPackPlugin extends XPackPlugin
.stream() .stream()
.map(SearchPlugin::getRequestCacheKeyDifferentiator) .map(SearchPlugin::getRequestCacheKeyDifferentiator)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList()); .toList();
if (differentiators.size() > 1) { if (differentiators.size() > 1) {
throw new UnsupportedOperationException("Only the security SearchPlugin should provide the request cache key differentiator"); throw new UnsupportedOperationException("Only the security SearchPlugin should provide the request cache key differentiator");

View file

@ -31,7 +31,6 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.hamcrest.Matchers.anEmptyMap; import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -53,7 +52,7 @@ public class GetServiceAccountCredentialsResponseTests extends ESTestCase {
final String principal = randomAlphaOfLengthBetween(3, 8) + "/" + randomAlphaOfLengthBetween(3, 8); final String principal = randomAlphaOfLengthBetween(3, 8) + "/" + randomAlphaOfLengthBetween(3, 8);
final List<TokenInfo> indexTokenInfos = IntStream.range(0, randomIntBetween(0, 10)) final List<TokenInfo> indexTokenInfos = IntStream.range(0, randomIntBetween(0, 10))
.mapToObj(i -> TokenInfo.indexToken(randomAlphaOfLengthBetween(3, 8))) .mapToObj(i -> TokenInfo.indexToken(randomAlphaOfLengthBetween(3, 8)))
.collect(Collectors.toUnmodifiableList()); .toList();
final GetServiceAccountCredentialsNodesResponse fileTokensResponse = randomGetServiceAccountFileTokensResponse(); final GetServiceAccountCredentialsNodesResponse fileTokensResponse = randomGetServiceAccountFileTokensResponse();
return new GetServiceAccountCredentialsResponse(principal, indexTokenInfos, fileTokensResponse); return new GetServiceAccountCredentialsResponse(principal, indexTokenInfos, fileTokensResponse);
} }
@ -130,7 +129,6 @@ public class GetServiceAccountCredentialsResponseTests extends ESTestCase {
} }
private List<TokenInfo> getAllTokenInfos(GetServiceAccountCredentialsResponse response) { private List<TokenInfo> getAllTokenInfos(GetServiceAccountCredentialsResponse response) {
return Stream.concat(response.getNodesResponse().getFileTokenInfos().stream(), response.getIndexTokenInfos().stream()) return Stream.concat(response.getNodesResponse().getFileTokenInfos().stream(), response.getIndexTokenInfos().stream()).toList();
.collect(toUnmodifiableList());
} }
} }

View file

@ -41,7 +41,6 @@ import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.stream.Collectors;
/** /**
* This class models the storage of a {@link SamlServiceProvider} as an Elasticsearch document. * This class models the storage of a {@link SamlServiceProvider} as an Elasticsearch document.
@ -171,14 +170,14 @@ public class SamlServiceProviderDocument implements ToXContentObject, Writeable
} catch (CertificateEncodingException e) { } catch (CertificateEncodingException e) {
throw new ElasticsearchException("Cannot read certificate", e); throw new ElasticsearchException("Cannot read certificate", e);
} }
}).map(Base64.getEncoder()::encodeToString).collect(Collectors.toUnmodifiableList()); }).map(Base64.getEncoder()::encodeToString).toList();
} }
private List<X509Certificate> decodeCertificates(List<String> encodedCertificates) { private List<X509Certificate> decodeCertificates(List<String> encodedCertificates) {
if (encodedCertificates == null || encodedCertificates.isEmpty()) { if (encodedCertificates == null || encodedCertificates.isEmpty()) {
return List.of(); return List.of();
} }
return encodedCertificates.stream().map(this::decodeCertificate).collect(Collectors.toUnmodifiableList()); return encodedCertificates.stream().map(this::decodeCertificate).toList();
} }
private X509Certificate decodeCertificate(String base64Cert) { private X509Certificate decodeCertificate(String base64Cert) {

View file

@ -29,7 +29,6 @@ import java.security.cert.X509Certificate;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent;
import static org.hamcrest.Matchers.emptyIterable; import static org.hamcrest.Matchers.emptyIterable;
@ -92,9 +91,7 @@ public class SamlServiceProviderDocumentTests extends IdpSamlTestCase {
private SamlServiceProviderDocument createFullDocument() throws GeneralSecurityException, IOException { private SamlServiceProviderDocument createFullDocument() throws GeneralSecurityException, IOException {
final List<X509Credential> credentials = readCredentials(); final List<X509Credential> credentials = readCredentials();
final List<X509Certificate> certificates = credentials.stream() final List<X509Certificate> certificates = credentials.stream().map(X509Credential::getEntityCertificate).toList();
.map(X509Credential::getEntityCertificate)
.collect(Collectors.toUnmodifiableList());
final List<X509Certificate> spCertificates = randomSubsetOf(certificates); final List<X509Certificate> spCertificates = randomSubsetOf(certificates);
final List<X509Certificate> idpCertificates = randomSubsetOf(certificates); final List<X509Certificate> idpCertificates = randomSubsetOf(certificates);
final List<X509Certificate> idpMetadataCertificates = randomSubsetOf(certificates); final List<X509Certificate> idpMetadataCertificates = randomSubsetOf(certificates);

View file

@ -11,18 +11,13 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.contains;
public class LogstashPluginTests extends ESTestCase { public class LogstashPluginTests extends ESTestCase {
public void testSystemIndices() { public void testSystemIndices() {
assertThat( assertThat(
new Logstash().getSystemIndexDescriptors(Settings.EMPTY) new Logstash().getSystemIndexDescriptors(Settings.EMPTY).stream().map(SystemIndexDescriptor::getIndexPattern).toList(),
.stream()
.map(SystemIndexDescriptor::getIndexPattern)
.collect(Collectors.toUnmodifiableList()),
contains(".logstash*") contains(".logstash*")
); );
} }

View file

@ -13,7 +13,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/** /**
* Tracks progress of a data frame analytics job. * Tracks progress of a data frame analytics job.
@ -127,8 +126,6 @@ public class ProgressTracker {
} }
public List<PhaseProgress> report() { public List<PhaseProgress> report() {
return Arrays.stream(phasesInOrder) return Arrays.stream(phasesInOrder).map(phase -> new PhaseProgress(phase, progressPercentPerPhase.get(phase))).toList();
.map(phase -> new PhaseProgress(phase, progressPercentPerPhase.get(phase)))
.collect(Collectors.toUnmodifiableList());
} }
} }

View file

@ -16,7 +16,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toUnmodifiableList;
import static java.util.stream.Collectors.toUnmodifiableMap; import static java.util.stream.Collectors.toUnmodifiableMap;
public final class DataTypes { public final class DataTypes {
@ -72,7 +71,7 @@ public final class DataTypes {
BINARY, BINARY,
OBJECT, OBJECT,
NESTED NESTED
).stream().sorted(Comparator.comparing(DataType::typeName)).collect(toUnmodifiableList()); ).stream().sorted(Comparator.comparing(DataType::typeName)).toList();
private static final Map<String, DataType> NAME_TO_TYPE = TYPES.stream().collect(toUnmodifiableMap(DataType::typeName, t -> t)); private static final Map<String, DataType> NAME_TO_TYPE = TYPES.stream().collect(toUnmodifiableMap(DataType::typeName, t -> t));

View file

@ -29,7 +29,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -53,9 +52,7 @@ public class OperatorPrivilegesIT extends ESRestTestCase {
getShutdownStatus.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER)); getShutdownStatus.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER));
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus)); Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes"); List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
List<String> nodeIds = nodesArray.stream() List<String> nodeIds = nodesArray.stream().map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id")).toList();
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))
.collect(Collectors.toUnmodifiableList());
for (String nodeId : nodeIds) { for (String nodeId : nodeIds) {
Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown"); Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown");
deleteRequest.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER)); deleteRequest.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", OPERATOR_AUTH_HEADER));

View file

@ -231,7 +231,7 @@ public class QueryApiKeyIT extends SecurityInBasicRestTestCase {
final int total = randomIntBetween(8, 12); final int total = randomIntBetween(8, 12);
final List<String> apiKeyNames = IntStream.range(0, total) final List<String> apiKeyNames = IntStream.range(0, total)
.mapToObj(i -> String.format(Locale.ROOT, "k-%02d", i)) .mapToObj(i -> String.format(Locale.ROOT, "k-%02d", i))
.collect(Collectors.toUnmodifiableList()); .toList();
final List<String> apiKeyIds = new ArrayList<>(total); final List<String> apiKeyIds = new ArrayList<>(total);
for (int i = 0; i < total; i++) { for (int i = 0; i < total; i++) {
apiKeyIds.add(createApiKey(apiKeyNames.get(i), null, authHeader).v1()); apiKeyIds.add(createApiKey(apiKeyNames.get(i), null, authHeader).v1());
@ -276,21 +276,21 @@ public class QueryApiKeyIT extends SecurityInBasicRestTestCase {
// assert sort values match the field of API key information // assert sort values match the field of API key information
if ("name".equals(sortField)) { if ("name".equals(sortField)) {
assertThat( assertThat(
apiKeyInfos.stream().map(m -> (String) m.get("name")).collect(Collectors.toUnmodifiableList()), apiKeyInfos.stream().map(m -> (String) m.get("name")).toList(),
equalTo(apiKeyInfos.stream().map(m -> (String) extractSortValues(m).get(0)).collect(Collectors.toUnmodifiableList())) equalTo(apiKeyInfos.stream().map(m -> (String) extractSortValues(m).get(0)).toList())
); );
} else { } else {
assertThat( assertThat(
apiKeyInfos.stream().map(m -> (long) m.get("creation")).collect(Collectors.toUnmodifiableList()), apiKeyInfos.stream().map(m -> (long) m.get("creation")).toList(),
equalTo(apiKeyInfos.stream().map(m -> (long) extractSortValues(m).get(0)).collect(Collectors.toUnmodifiableList())) equalTo(apiKeyInfos.stream().map(m -> (long) extractSortValues(m).get(0)).toList())
); );
} }
assertThat( assertThat(
apiKeyInfos.stream().map(m -> (String) m.get("id")).collect(Collectors.toUnmodifiableList()), apiKeyInfos.stream().map(m -> (String) m.get("id")).toList(),
equalTo(apiKeyIds.subList(from, total)) equalTo(apiKeyIds.subList(from, total))
); );
assertThat( assertThat(
apiKeyInfos.stream().map(m -> (String) m.get("name")).collect(Collectors.toUnmodifiableList()), apiKeyInfos.stream().map(m -> (String) m.get("name")).toList(),
equalTo(apiKeyNames.subList(from, total)) equalTo(apiKeyNames.subList(from, total))
); );

View file

@ -81,7 +81,7 @@ public class TransportNodeEnrollmentAction extends HandledTransportAction<NodeEn
final List<Tuple<PrivateKey, X509Certificate>> httpCaKeysAndCertificates = httpKeyConfig.getKeys() final List<Tuple<PrivateKey, X509Certificate>> httpCaKeysAndCertificates = httpKeyConfig.getKeys()
.stream() .stream()
.filter(t -> t.v2().getBasicConstraints() != -1) .filter(t -> t.v2().getBasicConstraints() != -1)
.collect(Collectors.toUnmodifiableList()); .toList();
if (transportKeysAndCertificates.isEmpty()) { if (transportKeysAndCertificates.isEmpty()) {
listener.onFailure( listener.onFailure(

View file

@ -1260,7 +1260,7 @@ public class ApiKeyService {
} }
final List<QueryApiKeyResponse.Item> apiKeyItem = Arrays.stream(searchResponse.getHits().getHits()) final List<QueryApiKeyResponse.Item> apiKeyItem = Arrays.stream(searchResponse.getHits().getHits())
.map(ApiKeyService::convertSearchHitToQueryItem) .map(ApiKeyService::convertSearchHitToQueryItem)
.collect(Collectors.toUnmodifiableList()); .toList();
listener.onResponse(new QueryApiKeyResponse(total, apiKeyItem)); listener.onResponse(new QueryApiKeyResponse(total, apiKeyItem));
}, listener::onFailure) }, listener::onFailure)
) )

View file

@ -167,7 +167,7 @@ public class Realms implements Iterable<Realm> {
} }
// Otherwise, we return anything in "all realms" that is not in the allowed realm list // Otherwise, we return anything in "all realms" that is not in the allowed realm list
return allConfiguredRealms.stream().filter(r -> activeSnapshot.contains(r) == false).collect(Collectors.toUnmodifiableList()); return allConfiguredRealms.stream().filter(r -> activeSnapshot.contains(r) == false).toList();
} }
public Stream<Realm> stream() { public Stream<Realm> stream() {
@ -181,7 +181,7 @@ public class Realms implements Iterable<Realm> {
// Protected for testing // Protected for testing
protected List<Realm> calculateLicensedRealms(XPackLicenseState licenseStateSnapshot) { protected List<Realm> calculateLicensedRealms(XPackLicenseState licenseStateSnapshot) {
return allConfiguredRealms.stream().filter(r -> checkLicense(r, licenseStateSnapshot)).collect(Collectors.toUnmodifiableList()); return allConfiguredRealms.stream().filter(r -> checkLicense(r, licenseStateSnapshot)).toList();
} }
private static boolean checkLicense(Realm realm, XPackLicenseState licenseState) { private static boolean checkLicense(Realm realm, XPackLicenseState licenseState) {

View file

@ -72,7 +72,7 @@ class ActiveDirectoryGroupsResolver implements GroupsResolver {
Math.toIntExact(timeout.seconds()), Math.toIntExact(timeout.seconds()),
ignoreReferralErrors, ignoreReferralErrors,
ActionListener.wrap((results) -> { ActionListener.wrap((results) -> {
List<String> groups = results.stream().map(SearchResultEntry::getDN).collect(Collectors.toUnmodifiableList()); List<String> groups = results.stream().map(SearchResultEntry::getDN).toList();
listener.onResponse(groups); listener.onResponse(groups);
}, listener::onFailure), }, listener::onFailure),
SearchRequest.NO_ATTRIBUTES SearchRequest.NO_ATTRIBUTES

View file

@ -24,7 +24,6 @@ import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession.GroupsRes
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import static org.elasticsearch.common.Strings.isNullOrEmpty; import static org.elasticsearch.common.Strings.isNullOrEmpty;
import static org.elasticsearch.xpack.core.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING; import static org.elasticsearch.xpack.core.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING;
@ -79,9 +78,7 @@ class SearchGroupsResolver implements GroupsResolver {
Math.toIntExact(timeout.seconds()), Math.toIntExact(timeout.seconds()),
ignoreReferralErrors, ignoreReferralErrors,
ActionListener.wrap( ActionListener.wrap(
(results) -> listener.onResponse( (results) -> listener.onResponse(results.stream().map((r) -> r.getDN()).toList()),
results.stream().map((r) -> r.getDN()).collect(Collectors.toUnmodifiableList())
),
listener::onFailure listener::onFailure
), ),
SearchRequest.NO_ATTRIBUTES SearchRequest.NO_ATTRIBUTES

View file

@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import static org.elasticsearch.xpack.core.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING; import static org.elasticsearch.xpack.core.security.authc.ldap.support.SessionFactorySettings.IGNORE_REFERRAL_ERRORS_SETTING;
import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.OBJECT_CLASS_PRESENCE_FILTER; import static org.elasticsearch.xpack.security.authc.ldap.support.LdapUtils.OBJECT_CLASS_PRESENCE_FILTER;
@ -57,7 +56,7 @@ class UserAttributeGroupsResolver implements GroupsResolver {
final List<String> groups = attributes.stream() final List<String> groups = attributes.stream()
.filter((attr) -> attr.getName().equals(attribute)) .filter((attr) -> attr.getName().equals(attribute))
.flatMap(attr -> Arrays.stream(attr.getValues())) .flatMap(attr -> Arrays.stream(attr.getValues()))
.collect(Collectors.toUnmodifiableList()); .toList();
listener.onResponse(groups); listener.onResponse(groups);
} else { } else {
searchForEntry( searchForEntry(

View file

@ -13,7 +13,6 @@ import org.opensaml.saml.saml2.core.NameIDType;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* An lightweight collection of SAML attributes * An lightweight collection of SAML attributes
@ -52,7 +51,7 @@ public class SamlAttributes {
return attributes.stream() return attributes.stream()
.filter(attr -> attributeId.equals(attr.name) || attributeId.equals(attr.friendlyName)) .filter(attr -> attributeId.equals(attr.name) || attributeId.equals(attr.friendlyName))
.flatMap(attr -> attr.values.stream()) .flatMap(attr -> attr.values.stream())
.collect(Collectors.toUnmodifiableList()); .toList();
} }
List<SamlAttribute> attributes() { List<SamlAttribute> attributes() {
@ -81,11 +80,7 @@ public class SamlAttributes {
this( this(
attribute.getName(), attribute.getName(),
attribute.getFriendlyName(), attribute.getFriendlyName(),
attribute.getAttributeValues() attribute.getAttributeValues().stream().map(x -> x.getDOM().getTextContent()).filter(Objects::nonNull).toList()
.stream()
.map(x -> x.getDOM().getTextContent())
.filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList())
); );
} }

View file

@ -905,7 +905,7 @@ public final class SamlRealm extends Realm implements Releasable {
return null; return null;
} }
return value; return value;
}).filter(Objects::nonNull).collect(Collectors.toUnmodifiableList()) }).filter(Objects::nonNull).toList()
); );
} else { } else {
return new AttributeParser( return new AttributeParser(

View file

@ -39,7 +39,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
public class FileServiceAccountTokenStore extends CachingServiceAccountTokenStore { public class FileServiceAccountTokenStore extends CachingServiceAccountTokenStore {
@ -103,7 +102,7 @@ public class FileServiceAccountTokenStore extends CachingServiceAccountTokenStor
List.of(clusterService.localNode().getName()) List.of(clusterService.localNode().getName())
) )
) )
.collect(Collectors.toUnmodifiableList()); .toList();
} }
public void addListener(Runnable listener) { public void addListener(Runnable listener) {

View file

@ -85,8 +85,8 @@ public class BaseEnrollmentTokenGenerator {
}; };
localAddresses.sort(ipv4BeforeIpv6Comparator); localAddresses.sort(ipv4BeforeIpv6Comparator);
nonLocalAddresses.sort(ipv4BeforeIpv6Comparator); nonLocalAddresses.sort(ipv4BeforeIpv6Comparator);
final List<String> distinctLocalAddresses = localAddresses.stream().distinct().collect(Collectors.toUnmodifiableList()); final List<String> distinctLocalAddresses = localAddresses.stream().distinct().toList();
final List<String> distinctNonLocalAddresses = nonLocalAddresses.stream().distinct().collect(Collectors.toUnmodifiableList()); final List<String> distinctNonLocalAddresses = nonLocalAddresses.stream().distinct().toList();
return new Tuple<>(distinctLocalAddresses, distinctNonLocalAddresses); return new Tuple<>(distinctLocalAddresses, distinctNonLocalAddresses);
} }

View file

@ -16,7 +16,6 @@ import org.elasticsearch.test.ESTestCase;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -35,9 +34,7 @@ public class TransportQueryApiKeyActionTests extends ESTestCase {
"metadata." + randomAlphaOfLengthBetween(3, 8) "metadata." + randomAlphaOfLengthBetween(3, 8)
); );
final List<FieldSortBuilder> originals = fieldNames.stream() final List<FieldSortBuilder> originals = fieldNames.stream().map(this::randomFieldSortBuilderWithName).toList();
.map(this::randomFieldSortBuilderWithName)
.collect(Collectors.toUnmodifiableList());
final SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.searchSource(); final SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.searchSource();
TransportQueryApiKeyAction.translateFieldSortBuilders(originals, searchSourceBuilder); TransportQueryApiKeyAction.translateFieldSortBuilders(originals, searchSourceBuilder);

View file

@ -53,7 +53,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -644,7 +643,7 @@ public class ServiceAccountServiceTests extends ESTestCase {
final List<TokenInfo> indexTokenInfos = IntStream.range(0, randomIntBetween(0, 3)) final List<TokenInfo> indexTokenInfos = IntStream.range(0, randomIntBetween(0, 3))
.mapToObj(i -> TokenInfo.indexToken(ValidationTests.randomTokenName())) .mapToObj(i -> TokenInfo.indexToken(ValidationTests.randomTokenName()))
.sorted() .sorted()
.collect(Collectors.toUnmodifiableList()); .toList();
doAnswer(inv -> { doAnswer(inv -> {
final Object[] args = inv.getArguments(); final Object[] args = inv.getArguments();

View file

@ -35,7 +35,6 @@ import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors;
import static org.elasticsearch.xpack.security.support.ApiKeyFieldNameTranslators.FIELD_NAME_TRANSLATORS; import static org.elasticsearch.xpack.security.support.ApiKeyFieldNameTranslators.FIELD_NAME_TRANSLATORS;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
@ -311,7 +310,7 @@ public class ApiKeyBoolQueryBuilderTests extends ESTestCase {
.stream() .stream()
.filter(q -> q.getClass() == TermQueryBuilder.class) .filter(q -> q.getClass() == TermQueryBuilder.class)
.map(q -> (TermQueryBuilder) q) .map(q -> (TermQueryBuilder) q)
.collect(Collectors.toUnmodifiableList()); .toList();
assertTrue(tqb.stream().anyMatch(q -> q.equals(QueryBuilders.termQuery("doc_type", "api_key")))); assertTrue(tqb.stream().anyMatch(q -> q.equals(QueryBuilders.termQuery("doc_type", "api_key"))));
if (authentication == null) { if (authentication == null) {
return; return;

View file

@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static java.util.Collections.unmodifiableMap; import static java.util.Collections.unmodifiableMap;
import static java.util.stream.Collectors.toUnmodifiableList;
import static java.util.stream.Collectors.toUnmodifiableMap; import static java.util.stream.Collectors.toUnmodifiableMap;
import static org.elasticsearch.xpack.ql.type.DataTypes.BINARY; import static org.elasticsearch.xpack.ql.type.DataTypes.BINARY;
import static org.elasticsearch.xpack.ql.type.DataTypes.BOOLEAN; import static org.elasticsearch.xpack.ql.type.DataTypes.BOOLEAN;
@ -163,7 +162,7 @@ public class SqlDataTypes {
GEO_POINT, GEO_POINT,
SHAPE SHAPE
) )
).sorted(Comparator.comparing(DataType::typeName)).collect(toUnmodifiableList()); ).sorted(Comparator.comparing(DataType::typeName)).toList();
private static final Map<String, DataType> NAME_TO_TYPE = TYPES.stream().collect(toUnmodifiableMap(DataType::typeName, t -> t)); private static final Map<String, DataType> NAME_TO_TYPE = TYPES.stream().collect(toUnmodifiableMap(DataType::typeName, t -> t));

View file

@ -30,7 +30,6 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
public class StackTemplateRegistry extends IndexTemplateRegistry { public class StackTemplateRegistry extends IndexTemplateRegistry {
@ -127,7 +126,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry {
new LifecyclePolicyConfig(ILM_90_DAYS_POLICY_NAME, "/" + ILM_90_DAYS_POLICY_NAME + ".json"), new LifecyclePolicyConfig(ILM_90_DAYS_POLICY_NAME, "/" + ILM_90_DAYS_POLICY_NAME + ".json"),
new LifecyclePolicyConfig(ILM_180_DAYS_POLICY_NAME, "/" + ILM_180_DAYS_POLICY_NAME + ".json"), new LifecyclePolicyConfig(ILM_180_DAYS_POLICY_NAME, "/" + ILM_180_DAYS_POLICY_NAME + ".json"),
new LifecyclePolicyConfig(ILM_365_DAYS_POLICY_NAME, "/" + ILM_365_DAYS_POLICY_NAME + ".json") new LifecyclePolicyConfig(ILM_365_DAYS_POLICY_NAME, "/" + ILM_365_DAYS_POLICY_NAME + ".json")
).map(config -> config.load(LifecyclePolicyConfig.DEFAULT_X_CONTENT_REGISTRY)).collect(Collectors.toUnmodifiableList()); ).map(config -> config.load(LifecyclePolicyConfig.DEFAULT_X_CONTENT_REGISTRY)).toList();
@Override @Override
protected List<LifecyclePolicy> getPolicyConfigs() { protected List<LifecyclePolicy> getPolicyConfigs() {