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("-XX:+PrintFlagsFinal"),
Stream.of("-version")
).reduce(Stream::concat).get().collect(Collectors.toUnmodifiableList());
).reduce(Stream::concat).get().toList();
final Process process = new ProcessBuilder().command(command).start();
final List<String> output = readLinesFromInputStream(process.getInputStream());
final List<String> error = readLinesFromInputStream(process.getErrorStream());
@ -119,7 +119,7 @@ class JvmOption {
private static List<String> readLinesFromInputStream(final InputStream is) throws IOException {
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);
if (esJavaOpts != null) {
jvmOptions.addAll(
Arrays.stream(esJavaOpts.split("\\s+")).filter(Predicate.not(String::isBlank)).collect(Collectors.toUnmodifiableList())
);
jvmOptions.addAll(Arrays.stream(esJavaOpts.split("\\s+")).filter(Predicate.not(String::isBlank)).toList());
}
final List<String> substitutedJvmOptions = substitutePlaceholders(jvmOptions, Collections.unmodifiableMap(substitutions));

View file

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

View file

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

View file

@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509ExtendedTrustManager;
@ -87,7 +86,7 @@ public final class PemTrustConfig implements SslTrustConfig {
}
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) {

View file

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

View file

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

View file

@ -12,18 +12,13 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.test.ESTestCase;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.contains;
public class KibanaPluginTests extends ESTestCase {
public void testKibanaIndexNames() {
assertThat(
new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY)
.stream()
.map(SystemIndexDescriptor::getIndexPattern)
.collect(Collectors.toUnmodifiableList()),
new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY).stream().map(SystemIndexDescriptor::getIndexPattern).toList(),
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.Objects;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
/**
@ -171,12 +170,10 @@ public abstract class SearchProgressListener {
.filter(Objects::nonNull)
.map(SearchPhaseResult::getSearchShardTarget)
.map(e -> new SearchShard(e.getClusterAlias(), e.getShardId()))
.collect(Collectors.toUnmodifiableList());
.toList();
}
static List<SearchShard> buildSearchShards(GroupShardsIterator<SearchShardIterator> its) {
return StreamSupport.stream(its.spliterator(), false)
.map(e -> new SearchShard(e.getClusterAlias(), e.shardId()))
.collect(Collectors.toUnmodifiableList());
return StreamSupport.stream(its.spliterator(), false).map(e -> new SearchShard(e.getClusterAlias(), e.shardId())).toList();
}
}

View file

@ -275,7 +275,7 @@ public class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole> {
static {
final List<Field> roleFields = Arrays.stream(DiscoveryNodeRole.class.getFields())
.filter(f -> f.getType().equals(DiscoveryNodeRole.class))
.collect(Collectors.toUnmodifiableList());
.toList();
// this will detect duplicate role names
final Map<String, DiscoveryNodeRole> roleMap = roleFields.stream().map(f -> {
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
*/
public List<RetentionLease> getPeerRecoveryRetentionLeases() {
return getRetentionLeases().leases()
.stream()
.filter(lease -> PEER_RECOVERY_RETENTION_LEASE_SOURCE.equals(lease.source()))
.collect(Collectors.toUnmodifiableList());
return getRetentionLeases().leases().stream().filter(lease -> PEER_RECOVERY_RETENTION_LEASE_SOURCE.equals(lease.source())).toList();
}
/**

View file

@ -15,7 +15,6 @@ import org.elasticsearch.cluster.metadata.Metadata;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 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
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.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static org.elasticsearch.indices.AssociatedIndexDescriptor.buildAutomaton;
@ -91,7 +90,7 @@ public class SystemDataStreamDescriptor {
* @return List of names of backing indices
*/
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() {

View file

@ -31,7 +31,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
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
@ -400,7 +399,7 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable<Sy
*/
@Override
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.Stream;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.elasticsearch.tasks.TaskResultsService.TASKS_DESCRIPTOR;
import static org.elasticsearch.tasks.TaskResultsService.TASKS_FEATURE_NAME;
@ -513,7 +512,7 @@ public class SystemIndices {
.stream()
.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
.collect(Collectors.toUnmodifiableList());
.toList();
List<Tuple<String, SystemDataStreamDescriptor>> sourceDataStreamDescriptorPair = sourceToFeature.entrySet()
.stream()
.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))
)
.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
// 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.v2().getAliasName() != null && descriptorToCheck.v2().matchesIndexPattern(d.v2().getAliasName()))
)
.collect(toUnmodifiableList());
.toList();
if (descriptorsMatchingThisPattern.isEmpty() == false) {
throw new IllegalStateException(
"a system index descriptor ["
@ -552,7 +551,7 @@ public class SystemIndices {
dsTuple -> descriptorToCheck.v2().matchesIndexPattern(dsTuple.v2().getDataStreamName())
|| overlaps(descriptorToCheck.v2().getIndexPattern(), dsTuple.v2().getBackingIndexPattern())
)
.collect(toUnmodifiableList());
.toList();
if (dataStreamsMatching.isEmpty() == false) {
throw new IllegalStateException(
"a system index descriptor ["

View file

@ -404,7 +404,7 @@ public class TaskManager implements ClusterStateApplier {
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.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
@ -445,7 +444,7 @@ public class TimeSeriesMetrics {
for (TimeSeriesMetricSelector selector : selectors) {
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) {

View file

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

View file

@ -15,7 +15,6 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.hamcrest.Matchers.is;
@ -84,7 +83,7 @@ public class IterablesTests extends ESTestCase {
final List<String> list = Stream.generate(() -> randomAlphaOfLengthBetween(3, 9))
.limit(randomIntBetween(10, 30))
.distinct()
.collect(Collectors.toUnmodifiableList());
.toList();
for (int i = 0; i < list.size(); i++) {
final String val = list.get(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(unsupportedZoneIdsPredicate.negate())
.sorted()
.collect(Collectors.toUnmodifiableList());
.toList();
JAVA_ZONE_IDS = ZoneId.getAvailableZoneIds()
.stream()
.filter(unsupportedZoneIdsPredicate.negate())
.sorted()
.collect(Collectors.toUnmodifiableList());
JAVA_ZONE_IDS = ZoneId.getAvailableZoneIds().stream().filter(unsupportedZoneIdsPredicate.negate()).sorted().toList();
}
@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) {
return Settings.builder()
.put(settings)
.putList(
NodeRoleSettings.NODE_ROLES_SETTING.getKey(),
roles.stream().map(DiscoveryNodeRole::roleName).collect(Collectors.toUnmodifiableList())
)
.putList(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), roles.stream().map(DiscoveryNodeRole::roleName).toList())
.build();
}
@ -57,7 +54,7 @@ public class NodeRoles {
.stream()
.filter(Predicate.not(roles::contains))
.map(DiscoveryNodeRole::roleName)
.collect(Collectors.toUnmodifiableList())
.toList()
);
return builder.build();
}
@ -73,7 +70,7 @@ public class NodeRoles {
Stream.concat(NodeRoleSettings.NODE_ROLES_SETTING.get(settings).stream(), roles.stream())
.map(DiscoveryNodeRole::roleName)
.distinct()
.collect(Collectors.toUnmodifiableList())
.toList()
);
return builder.build();
}

View file

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

View file

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

View file

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

View file

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

View file

@ -50,7 +50,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ -504,7 +503,7 @@ public class AutoFollowIT extends CcrIntegTestCase {
final String pattern = prefix + "pattern";
putAutoFollowPatterns(pattern, new String[] { prefix + "*" });
return pattern;
}).collect(toUnmodifiableList());
}).toList();
// pick up some random pattern to pause
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(
"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,
LicenseService::validateUploadTypesSetting,
Setting.Property.NodeScope
@ -642,7 +642,7 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
}
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) {

View file

@ -14,7 +14,6 @@ import org.elasticsearch.xpack.core.XPackFeatureSet;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
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
final List<XPackFeatureSet.Usage> usagesToWrite = usages.stream()
.filter(usage -> out.getVersion().onOrAfter(usage.getMinimalSupportedVersion()))
.collect(Collectors.toUnmodifiableList());
.toList();
writeTo(out, usagesToWrite);
}

View file

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

View file

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

View file

@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 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()
.stream()
.map(entry -> TokenInfo.fileToken(entry.getKey(), entry.getValue().stream().sorted().collect(Collectors.toUnmodifiableList())))
.collect(Collectors.toUnmodifiableList());
.map(entry -> TokenInfo.fileToken(entry.getKey(), entry.getValue().stream().sorted().toList()))
.toList();
}
public static class Node extends BaseNodeResponse {

View file

@ -18,8 +18,6 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static java.util.stream.Collectors.toUnmodifiableList;
public class GetServiceAccountCredentialsResponse extends ActionResponse implements ToXContentObject {
private final String principal;
@ -32,7 +30,7 @@ public class GetServiceAccountCredentialsResponse extends ActionResponse impleme
GetServiceAccountCredentialsNodesResponse nodesResponse
) {
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;
}

View file

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

View file

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

View file

@ -36,7 +36,6 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
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.SHOULD;
@ -151,10 +150,10 @@ public final class DocumentPermissions implements CacheKey {
private void evaluateQueries(DlsQueryEvaluationContext context) {
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) {
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.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;
/**
* Translates cluster privilege names into concrete implementations
@ -319,7 +318,7 @@ public class ClusterPrivilegeResolver {
.stream()
.filter(e -> e.getValue().permission().check(action, request, authentication))
.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.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static java.util.Map.entry;
import static org.elasticsearch.xpack.core.security.support.Automatons.patterns;
@ -253,10 +252,6 @@ public final class IndexPrivilege extends Privilege {
* @see Privilege#sortByAccessLevel
*/
public static Collection<String> findPrivilegesThatGrant(String action) {
return VALUES.entrySet()
.stream()
.filter(e -> e.getValue().predicate.test(action))
.map(e -> e.getKey())
.collect(Collectors.toUnmodifiableList());
return VALUES.entrySet().stream().filter(e -> e.getValue().predicate.test(action)).map(e -> e.getKey()).toList();
}
}

View file

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

View file

@ -41,7 +41,6 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
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.SINGLE_NODE_DISCOVERY_TYPE;
@ -93,7 +92,7 @@ public class LicenseServiceTests extends ESTestCase {
randomIntBetween(1, LicenseService.ALLOWABLE_UPLOAD_TYPES.size() - 1),
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();
assertRegisterValidLicense(settings, randomFrom(allowed));
}
@ -107,7 +106,7 @@ public class LicenseServiceTests extends ESTestCase {
randomIntBetween(1, LicenseService.ALLOWABLE_UPLOAD_TYPES.size() - 2),
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 License.LicenseType notAllowed = randomValueOtherThanMany(
test -> allowed.contains(test),

View file

@ -694,7 +694,7 @@ public class LocalStateCompositeXPackPlugin extends XPackPlugin
.stream()
.map(SearchPlugin::getRequestCacheKeyDifferentiator)
.filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList());
.toList();
if (differentiators.size() > 1) {
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.Stream;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.equalTo;
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 List<TokenInfo> indexTokenInfos = IntStream.range(0, randomIntBetween(0, 10))
.mapToObj(i -> TokenInfo.indexToken(randomAlphaOfLengthBetween(3, 8)))
.collect(Collectors.toUnmodifiableList());
.toList();
final GetServiceAccountCredentialsNodesResponse fileTokensResponse = randomGetServiceAccountFileTokensResponse();
return new GetServiceAccountCredentialsResponse(principal, indexTokenInfos, fileTokensResponse);
}
@ -130,7 +129,6 @@ public class GetServiceAccountCredentialsResponseTests extends ESTestCase {
}
private List<TokenInfo> getAllTokenInfos(GetServiceAccountCredentialsResponse response) {
return Stream.concat(response.getNodesResponse().getFileTokenInfos().stream(), response.getIndexTokenInfos().stream())
.collect(toUnmodifiableList());
return Stream.concat(response.getNodesResponse().getFileTokenInfos().stream(), response.getIndexTokenInfos().stream()).toList();
}
}

View file

@ -41,7 +41,6 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
/**
* 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) {
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) {
if (encodedCertificates == null || encodedCertificates.isEmpty()) {
return List.of();
}
return encodedCertificates.stream().map(this::decodeCertificate).collect(Collectors.toUnmodifiableList());
return encodedCertificates.stream().map(this::decodeCertificate).toList();
}
private X509Certificate decodeCertificate(String base64Cert) {

View file

@ -29,7 +29,6 @@ import java.security.cert.X509Certificate;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent;
import static org.hamcrest.Matchers.emptyIterable;
@ -92,9 +91,7 @@ public class SamlServiceProviderDocumentTests extends IdpSamlTestCase {
private SamlServiceProviderDocument createFullDocument() throws GeneralSecurityException, IOException {
final List<X509Credential> credentials = readCredentials();
final List<X509Certificate> certificates = credentials.stream()
.map(X509Credential::getEntityCertificate)
.collect(Collectors.toUnmodifiableList());
final List<X509Certificate> certificates = credentials.stream().map(X509Credential::getEntityCertificate).toList();
final List<X509Certificate> spCertificates = randomSubsetOf(certificates);
final List<X509Certificate> idpCertificates = 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.test.ESTestCase;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.contains;
public class LogstashPluginTests extends ESTestCase {
public void testSystemIndices() {
assertThat(
new Logstash().getSystemIndexDescriptors(Settings.EMPTY)
.stream()
.map(SystemIndexDescriptor::getIndexPattern)
.collect(Collectors.toUnmodifiableList()),
new Logstash().getSystemIndexDescriptors(Settings.EMPTY).stream().map(SystemIndexDescriptor::getIndexPattern).toList(),
contains(".logstash*")
);
}

View file

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

View file

@ -16,7 +16,6 @@ import java.util.Locale;
import java.util.Map;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toUnmodifiableList;
import static java.util.stream.Collectors.toUnmodifiableMap;
public final class DataTypes {
@ -72,7 +71,7 @@ public final class DataTypes {
BINARY,
OBJECT,
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));

View file

@ -29,7 +29,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.containsString;
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));
Map<String, Object> statusResponse = responseAsMap(adminClient().performRequest(getShutdownStatus));
List<Map<String, Object>> nodesArray = (List<Map<String, Object>>) statusResponse.get("nodes");
List<String> nodeIds = nodesArray.stream()
.map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id"))
.collect(Collectors.toUnmodifiableList());
List<String> nodeIds = nodesArray.stream().map(nodeShutdownMetadata -> (String) nodeShutdownMetadata.get("node_id")).toList();
for (String nodeId : nodeIds) {
Request deleteRequest = new Request("DELETE", "_nodes/" + nodeId + "/shutdown");
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 List<String> apiKeyNames = IntStream.range(0, total)
.mapToObj(i -> String.format(Locale.ROOT, "k-%02d", i))
.collect(Collectors.toUnmodifiableList());
.toList();
final List<String> apiKeyIds = new ArrayList<>(total);
for (int i = 0; i < total; i++) {
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
if ("name".equals(sortField)) {
assertThat(
apiKeyInfos.stream().map(m -> (String) m.get("name")).collect(Collectors.toUnmodifiableList()),
equalTo(apiKeyInfos.stream().map(m -> (String) extractSortValues(m).get(0)).collect(Collectors.toUnmodifiableList()))
apiKeyInfos.stream().map(m -> (String) m.get("name")).toList(),
equalTo(apiKeyInfos.stream().map(m -> (String) extractSortValues(m).get(0)).toList())
);
} else {
assertThat(
apiKeyInfos.stream().map(m -> (long) m.get("creation")).collect(Collectors.toUnmodifiableList()),
equalTo(apiKeyInfos.stream().map(m -> (long) extractSortValues(m).get(0)).collect(Collectors.toUnmodifiableList()))
apiKeyInfos.stream().map(m -> (long) m.get("creation")).toList(),
equalTo(apiKeyInfos.stream().map(m -> (long) extractSortValues(m).get(0)).toList())
);
}
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))
);
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))
);

View file

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

View file

@ -1260,7 +1260,7 @@ public class ApiKeyService {
}
final List<QueryApiKeyResponse.Item> apiKeyItem = Arrays.stream(searchResponse.getHits().getHits())
.map(ApiKeyService::convertSearchHitToQueryItem)
.collect(Collectors.toUnmodifiableList());
.toList();
listener.onResponse(new QueryApiKeyResponse(total, apiKeyItem));
}, 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
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() {
@ -181,7 +181,7 @@ public class Realms implements Iterable<Realm> {
// Protected for testing
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) {

View file

@ -72,7 +72,7 @@ class ActiveDirectoryGroupsResolver implements GroupsResolver {
Math.toIntExact(timeout.seconds()),
ignoreReferralErrors,
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::onFailure),
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.List;
import java.util.stream.Collectors;
import static org.elasticsearch.common.Strings.isNullOrEmpty;
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()),
ignoreReferralErrors,
ActionListener.wrap(
(results) -> listener.onResponse(
results.stream().map((r) -> r.getDN()).collect(Collectors.toUnmodifiableList())
),
(results) -> listener.onResponse(results.stream().map((r) -> r.getDN()).toList()),
listener::onFailure
),
SearchRequest.NO_ATTRIBUTES

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.Collections.unmodifiableMap;
import static java.util.stream.Collectors.toUnmodifiableList;
import static java.util.stream.Collectors.toUnmodifiableMap;
import static org.elasticsearch.xpack.ql.type.DataTypes.BINARY;
import static org.elasticsearch.xpack.ql.type.DataTypes.BOOLEAN;
@ -163,7 +162,7 @@ public class SqlDataTypes {
GEO_POINT,
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));

View file

@ -30,7 +30,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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_180_DAYS_POLICY_NAME, "/" + ILM_180_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
protected List<LifecyclePolicy> getPolicyConfigs() {