Replace Collection#addAll to call constructor

See gh-17847
pull/17864/head
lijuny 5 years ago committed by Stephane Nicoll
parent f8f3733e1c
commit 200de49c11

@ -38,8 +38,8 @@ final class HealthIndicatorRegistryBeans {
}
static HealthIndicatorRegistry get(ApplicationContext applicationContext) {
Map<String, HealthIndicator> indicators = new LinkedHashMap<>();
indicators.putAll(applicationContext.getBeansOfType(HealthIndicator.class));
Map<String, HealthIndicator> indicators = new LinkedHashMap<>(
applicationContext.getBeansOfType(HealthIndicator.class));
if (ClassUtils.isPresent("reactor.core.publisher.Flux", null)) {
new ReactiveHealthIndicators().get(applicationContext).forEach(indicators::putIfAbsent);
}

@ -74,8 +74,7 @@ class CompositeHandlerAdapter implements HandlerAdapter {
}
private List<HandlerAdapter> extractAdapters() {
List<HandlerAdapter> list = new ArrayList<>();
list.addAll(this.beanFactory.getBeansOfType(HandlerAdapter.class).values());
List<HandlerAdapter> list = new ArrayList<>(this.beanFactory.getBeansOfType(HandlerAdapter.class).values());
list.remove(this);
AnnotationAwareOrderComparator.sort(list);
return list;

@ -55,8 +55,8 @@ class CompositeHandlerExceptionResolver implements HandlerExceptionResolver {
}
private List<HandlerExceptionResolver> extractResolvers() {
List<HandlerExceptionResolver> list = new ArrayList<>();
list.addAll(this.beanFactory.getBeansOfType(HandlerExceptionResolver.class).values());
List<HandlerExceptionResolver> list = new ArrayList<>(
this.beanFactory.getBeansOfType(HandlerExceptionResolver.class).values());
list.remove(this);
AnnotationAwareOrderComparator.sort(list);
if (list.isEmpty()) {

@ -56,8 +56,7 @@ class CompositeHandlerMapping implements HandlerMapping {
}
private List<HandlerMapping> extractMappings() {
List<HandlerMapping> list = new ArrayList<>();
list.addAll(this.beanFactory.getBeansOfType(HandlerMapping.class).values());
List<HandlerMapping> list = new ArrayList<>(this.beanFactory.getBeansOfType(HandlerMapping.class).values());
list.remove(this);
AnnotationAwareOrderComparator.sort(list);
return list;

Loading…
Cancel
Save