From 422a436df19d8edab11e72ad1b91aca744cabcad Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Sun, 8 Jul 2018 18:12:05 +0200 Subject: [PATCH 1/2] Polish some Collectors See gh-13727 --- .../endpoint/ExposeExcludePropertyEndpointFilter.java | 3 +-- .../boot/actuate/metrics/MetricsEndpoint.java | 2 +- .../boot/autoconfigure/AutoConfigurations.java | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java index d61b0370c9b..c2b2e769b87 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.stream.Collectors; @@ -83,7 +82,7 @@ public class ExposeExcludePropertyEndpointFilter> return Collections.emptySet(); } return items.stream().map((item) -> item.toLowerCase(Locale.ENGLISH)) - .collect(Collectors.toCollection(HashSet::new)); + .collect(Collectors.toSet()); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java index fbe4da8f49b..2e2ebd7e8e2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java @@ -158,7 +158,7 @@ public class MetricsEndpoint { private List asList(Map map, BiFunction mapper) { return map.entrySet().stream() .map((entry) -> mapper.apply(entry.getKey(), entry.getValue())) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(Collectors.toList()); } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java index b611cf3b3da..ea5c50fa034 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -48,11 +47,11 @@ public class AutoConfigurations extends Configurations implements Ordered { @Override protected Collection> sort(Collection> classes) { List names = classes.stream().map(Class::getName) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(Collectors.toList()); List sorted = SORTER.getInPriorityOrder(names); return sorted.stream() .map((className) -> ClassUtils.resolveClassName(className, null)) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(Collectors.toList()); } @Override From d9c0dbb99d827b4fb98f7a1b11f28019affc935d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 27 Aug 2018 18:09:19 +0200 Subject: [PATCH 2/2] Polish "Polish some Collectors" Closes gh-13727 --- .../springframework/boot/autoconfigure/AutoConfigurations.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java index ea5c50fa034..4fdcd35bc06 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java @@ -16,6 +16,7 @@ package org.springframework.boot.autoconfigure; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -51,7 +52,7 @@ public class AutoConfigurations extends Configurations implements Ordered { List sorted = SORTER.getInPriorityOrder(names); return sorted.stream() .map((className) -> ClassUtils.resolveClassName(className, null)) - .collect(Collectors.toList()); + .collect(Collectors.toCollection(ArrayList::new)); } @Override