From 200de49c11c25f98220e39c3a10686f86ad16d25 Mon Sep 17 00:00:00 2001 From: lijuny <1920271554@qq.com> Date: Tue, 13 Aug 2019 07:49:33 +0800 Subject: [PATCH] Replace Collection#addAll to call constructor See gh-17847 --- .../autoconfigure/health/HealthIndicatorRegistryBeans.java | 4 ++-- .../autoconfigure/web/servlet/CompositeHandlerAdapter.java | 3 +-- .../web/servlet/CompositeHandlerExceptionResolver.java | 4 ++-- .../autoconfigure/web/servlet/CompositeHandlerMapping.java | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorRegistryBeans.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorRegistryBeans.java index 2a1f09c9b9..6d8f4fb3d4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorRegistryBeans.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorRegistryBeans.java @@ -38,8 +38,8 @@ final class HealthIndicatorRegistryBeans { } static HealthIndicatorRegistry get(ApplicationContext applicationContext) { - Map indicators = new LinkedHashMap<>(); - indicators.putAll(applicationContext.getBeansOfType(HealthIndicator.class)); + Map indicators = new LinkedHashMap<>( + applicationContext.getBeansOfType(HealthIndicator.class)); if (ClassUtils.isPresent("reactor.core.publisher.Flux", null)) { new ReactiveHealthIndicators().get(applicationContext).forEach(indicators::putIfAbsent); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java index 9918ca55f9..a116a10a92 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerAdapter.java @@ -74,8 +74,7 @@ class CompositeHandlerAdapter implements HandlerAdapter { } private List extractAdapters() { - List list = new ArrayList<>(); - list.addAll(this.beanFactory.getBeansOfType(HandlerAdapter.class).values()); + List list = new ArrayList<>(this.beanFactory.getBeansOfType(HandlerAdapter.class).values()); list.remove(this); AnnotationAwareOrderComparator.sort(list); return list; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java index adff968d14..6d7b7121e3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerExceptionResolver.java @@ -55,8 +55,8 @@ class CompositeHandlerExceptionResolver implements HandlerExceptionResolver { } private List extractResolvers() { - List list = new ArrayList<>(); - list.addAll(this.beanFactory.getBeansOfType(HandlerExceptionResolver.class).values()); + List list = new ArrayList<>( + this.beanFactory.getBeansOfType(HandlerExceptionResolver.class).values()); list.remove(this); AnnotationAwareOrderComparator.sort(list); if (list.isEmpty()) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerMapping.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerMapping.java index dd42a6ac37..cacc8674f1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/CompositeHandlerMapping.java @@ -56,8 +56,7 @@ class CompositeHandlerMapping implements HandlerMapping { } private List extractMappings() { - List list = new ArrayList<>(); - list.addAll(this.beanFactory.getBeansOfType(HandlerMapping.class).values()); + List list = new ArrayList<>(this.beanFactory.getBeansOfType(HandlerMapping.class).values()); list.remove(this); AnnotationAwareOrderComparator.sort(list); return list;