From b1158bf35d4be6a871530d18f404b4fd511b6bb2 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Thu, 5 Dec 2019 08:05:21 +0100 Subject: [PATCH] Simplify some Stream API usages See gh-19291 --- .../boot/actuate/health/NamedContributorsMapAdapter.java | 2 +- .../boot/actuate/health/SimpleStatusAggregator.java | 2 +- .../mongo/embedded/EmbeddedMongoAutoConfigurationTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/NamedContributorsMapAdapter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/NamedContributorsMapAdapter.java index 4645ad047b..68ceb77daa 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/NamedContributorsMapAdapter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/NamedContributorsMapAdapter.java @@ -43,7 +43,7 @@ abstract class NamedContributorsMapAdapter implements NamedContributors NamedContributorsMapAdapter(Map map, Function valueAdapter) { Assert.notNull(map, "Map must not be null"); Assert.notNull(valueAdapter, "ValueAdapter must not be null"); - map.keySet().stream().forEach((key) -> Assert.notNull(key, "Map must not contain null keys")); + map.keySet().forEach((key) -> Assert.notNull(key, "Map must not contain null keys")); map.values().stream().map(valueAdapter) .forEach((value) -> Assert.notNull(value, "Map must not contain null values")); this.map = Collections.unmodifiableMap(new LinkedHashMap<>(map)); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java index 37f75fbee5..748dac1550 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleStatusAggregator.java @@ -69,7 +69,7 @@ public class SimpleStatusAggregator implements StatusAggregator { @Override public Status getAggregateStatus(Set statuses) { - return statuses.stream().filter(this::contains).sorted(this.comparator).findFirst().orElse(Status.UNKNOWN); + return statuses.stream().filter(this::contains).min(this.comparator).orElse(Status.UNKNOWN); } private boolean contains(Status status) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java index 622bb9c146..7f3cde68c6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java @@ -96,7 +96,7 @@ class EmbeddedMongoAutoConfigurationTests { features.add(Feature.ONLY_WINDOWS_2008_SERVER); } load("spring.mongodb.embedded.features=" - + String.join(", ", features.stream().map(Feature::name).collect(Collectors.toList()))); + + features.stream().map(Feature::name).collect(Collectors.joining(", "))); assertThat(this.context.getBean(EmbeddedMongoProperties.class).getFeatures()) .containsExactlyElementsOf(features); }