diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-18 07:13:53 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-18 07:13:53 +0100 |
commit | 592674c7317fd1e97107ed700fb7a039ef9365a7 (patch) | |
tree | 20a129c1f77a137c5c9d6cc2404ccc9b8743002d /controller-server | |
parent | 88a74a85691ee861f89669954a317781db000ab9 (diff) |
Just use Streams.toList as that is unmdifiable.
Diffstat (limited to 'controller-server')
13 files changed, 19 insertions, 21 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java index 3bc2aec95ff..6a493f3f5ed 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java @@ -235,7 +235,7 @@ public class AthenzFacade implements AccessControl { return tenants.stream() .filter(tenant -> tenant.type() == Tenant.Type.athenz && userDomains.apply(identity).contains(((AthenzTenant) tenant).domain())) - .collect(Collectors.toUnmodifiableList()); + .toList(); } public void addTenantAdmin(AthenzDomain tenantDomain, AthenzUser user) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java index 3c2dbcb8633..a5cb839e9c9 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java @@ -152,7 +152,7 @@ public class DeploymentTrigger { .collect(groupingBy(Job::applicationId)) .values().stream() .flatMap(List::stream) - .collect(Collectors.toUnmodifiableList()); + .toList(); // Map of test jobs, a list for each job type. Jobs in each list are sorted by priority. Map<JobType, List<Job>> sortedTestJobsByType = testJobs.stream() diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index 9c983eb5a0f..674d71001e3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -94,7 +94,6 @@ import static java.util.Comparator.naturalOrder; import static java.util.function.Predicate.not; import static java.util.logging.Level.INFO; import static java.util.logging.Level.WARNING; -import static java.util.stream.Collectors.toUnmodifiableList; /** * A singleton owned by the controller, which contains the state and methods for controlling deployment jobs. diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java index 71ff28c47e6..fd1e5592608 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java @@ -307,7 +307,7 @@ public class Run { .allMatch(step -> steps.get(step) == null || steps.get(step).status() == succeeded)) .map(Map.Entry::getKey) - .collect(Collectors.toUnmodifiableList()); + .toList(); } /** Returns the list of not-yet-run run-always steps whose run-always prerequisites have all run. */ @@ -320,7 +320,7 @@ public class Run { .allMatch(step -> steps.get(step) == null || steps.get(step).status() != unfinished)) .map(Map.Entry::getKey) - .collect(Collectors.toUnmodifiableList()); + .toList(); } private void requireActive() { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/SupportAccessSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/SupportAccessSerializer.java index a913e86dda9..af7c03f8657 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/SupportAccessSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/SupportAccessSerializer.java @@ -124,7 +124,7 @@ public class SupportAccessSerializer { inspector.field(requestorFieldName).asString(), X509CertificateUtils.fromPem(inspector.field(certificateFieldName).asString()) )) - .collect(Collectors.toUnmodifiableList()); + .toList(); List<SupportAccessChange> changeHistory = SlimeUtils.entriesStream(slime.get().field(historyFieldName)) .map(inspector -> @@ -133,7 +133,7 @@ public class SupportAccessSerializer { Instant.parse(inspector.field(atFieldName).asString()), inspector.field(byFieldName).asString()) ) - .collect(Collectors.toUnmodifiableList()); + .toList(); return new SupportAccess(changeHistory, grantHistory); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/TenantSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/TenantSerializer.java index d4536da91fe..f6b28a2ee34 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/TenantSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/TenantSerializer.java @@ -271,7 +271,7 @@ public class TenantSerializer { inspector.field(nameField).asString(), inspector.field(awsIdField).asString(), inspector.field(roleField).asString())) - .collect(Collectors.toUnmodifiableList()); + .toList(); } private LastLoginInfo lastLoginInfoFromSlime(Inspector lastLoginInfoObject) { @@ -337,7 +337,7 @@ public class TenantSerializer { private TenantContacts tenantContactsFrom(Inspector object) { List<TenantContacts.Contact> contacts = SlimeUtils.entriesStream(object) .map(this::readContact) - .collect(Collectors.toUnmodifiableList()); + .toList(); return new TenantContacts(contacts); } @@ -405,7 +405,7 @@ public class TenantSerializer { .orElseThrow(() -> new RuntimeException("Unknown type: " + inspector.field("type").asString())); var audiences = SlimeUtils.entriesStream(inspector.field("audiences")) .map(audience -> TenantSerializer.fromAudience(audience.asString())) - .collect(Collectors.toUnmodifiableList()); + .toList(); switch (type) { case EMAIL: var isVerified = asBoolOrTrue(inspector.field("data").field("emailVerified")); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserFlagsSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserFlagsSerializer.java index 44d537883f9..54a24360b5a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserFlagsSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserFlagsSerializer.java @@ -36,7 +36,7 @@ public class UserFlagsSerializer { .filter(fd -> fd.getDimensions().contains(FetchVector.Dimension.CONSOLE_USER_EMAIL)) .map(FlagDefinition::getUnboundFlag) .map(flag -> filteredFlagData(flag, Optional.ofNullable(rawFlagData.get(flag.id())), authorizedForTenantNames, isOperator, resolveVector)) - .collect(Collectors.toUnmodifiableList()); + .toList(); byte[] bytes = FlagData.serializeListToUtf8Json(filteredFlagData); SlimeUtils.copyObject(SlimeUtils.jsonToSlime(bytes).get(), cursor); @@ -55,10 +55,10 @@ public class UserFlagsSerializer { .map(rule -> new Rule(rule.getValueToApply().or(() -> defaultValue), rule.conditions().stream() .flatMap(condition -> filteredCondition(condition, authorizedForTenantNames, isOperator, resolveVector).stream()) - .collect(Collectors.toUnmodifiableList()))) + .toList())) // We can stop as soon as we hit the first rule that has no conditions .takeWhile(rule -> !encounteredEmpty.getAndSet(rule.conditions().isEmpty())) - .collect(Collectors.toUnmodifiableList()); + .toList(); return new FlagData(definition.id(), new FetchVector(), rules); } @@ -80,7 +80,7 @@ public class UserFlagsSerializer { private static Optional<Condition> valueSubset(Condition condition, Predicate<String> predicate) { Condition.CreateParams createParams = condition.toCreateParams(); return Optional.of(createParams - .withValues(createParams.values().stream().filter(predicate).collect(Collectors.toUnmodifiableList())) + .withValues(createParams.values().stream().filter(predicate).toList()) .createAs(condition.type())); } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccess.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccess.java index 27cf61564aa..e5304a05d02 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccess.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccess.java @@ -71,7 +71,7 @@ public class SupportAccess { private <T> List<T> prepend(T newEntry, List<T> existingEntries) { return Stream.concat(Stream.of(newEntry), existingEntries.stream()) // latest change first - .collect(Collectors.toUnmodifiableList()); + .toList(); } public static class CurrentStatus { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccessControl.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccessControl.java index 27b61a4fd17..1561a486fda 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccessControl.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/support/access/SupportAccessControl.java @@ -88,7 +88,7 @@ public class SupportAccessControl { return supportAccess.grantHistory().stream() .filter(grant -> now.isAfter(grant.certificate().getNotBefore().toInstant())) .filter(grant -> now.isBefore(grant.certificate().getNotAfter().toInstant())) - .collect(Collectors.toUnmodifiableList()); + .toList(); } public boolean allowDataplaneMembership(AthenzUser identity, DeploymentId deploymentId) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index 2c1d7315adc..93b804805c3 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -336,7 +336,7 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer public List<LoadBalancer> getLoadBalancers(ApplicationId application, ZoneId zone) { return getLoadBalancers(zone).stream() .filter(lb -> lb.application().equals(application)) - .collect(Collectors.toUnmodifiableList()); + .toList(); } @Override diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainerTest.java index 1f92c7f6e41..157abe17841 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainerTest.java @@ -152,6 +152,6 @@ public class ResourceMeterMaintainerTest { .clusterId("clusterA") .clusterType(state == Node.State.active ? Node.ClusterType.admin : Node.ClusterType.container) .build()) - .collect(Collectors.toUnmodifiableList()); + .toList(); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java index eb5422f5cff..59433a6bb69 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/BufferedLogStoreTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Optional; import java.util.stream.IntStream; -import static java.util.stream.Collectors.toUnmodifiableList; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -100,7 +99,7 @@ public class BufferedLogStoreTest { // Logging a large entry enough times to reach the maximum size causes no further entries to be stored. List<LogEntry> monsterLog = IntStream.range(0, 2 * maxChunks + 3) .mapToObj(i -> new LogEntry(i, entry.at(), entry.type(), entry.message())) - .collect(toUnmodifiableList()); + .toList(); List<LogEntry> logged = new ArrayList<>(monsterLog); logged.remove(logged.size() - 1); logged.remove(logged.size() - 1); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/rotation/RotationRepositoryTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/rotation/RotationRepositoryTest.java index cd8a9e72051..43ad01fc5c2 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/rotation/RotationRepositoryTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/rotation/RotationRepositoryTest.java @@ -209,7 +209,7 @@ public class RotationRepositoryTest { } private static List<RotationId> rotationIds(List<AssignedRotation> assignedRotations) { - return assignedRotations.stream().map(AssignedRotation::rotationId).collect(Collectors.toUnmodifiableList()); + return assignedRotations.stream().map(AssignedRotation::rotationId).toList(); } } |