Replace Collection#addAll to call constructor

See gh-17847
This commit is contained in:
lijuny 2019-08-13 07:49:33 +08:00 committed by Stephane Nicoll
parent f8f3733e1c
commit 200de49c11
4 changed files with 6 additions and 8 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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()) {

View File

@ -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;