diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
index e1846517e7..1b4ea1ed7c 100644
--- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
+++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-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.
@@ -20,7 +20,6 @@ import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
@@ -155,7 +154,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
methods.add(method);
}
});
- Collections.sort(methods, METHOD_COMPARATOR);
+ methods.sort(METHOD_COMPARATOR);
return methods;
}
@@ -164,7 +163,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
* for the given introduction field.
*
Resulting Advisors will need to be evaluated for targets.
* @param introductionField the field to introspect
- * @return {@code null} if not an Advisor
+ * @return the Advisor instance, or {@code null} if not an Advisor
*/
@Nullable
private Advisor getDeclareParentsAdvisor(Field introductionField) {
@@ -293,6 +292,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
springAdvice.setArgumentNamesFromStringArray(argNames);
}
springAdvice.calculateArgumentBindings();
+
return springAdvice;
}
@@ -307,7 +307,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
super(aif.getAspectMetadata().getPerClausePointcut(), (MethodBeforeAdvice)
- (method, args, target) -> aif.getAspectInstance());// Simply instantiate the aspect
+ (method, args, target) -> aif.getAspectInstance());
}
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
index 578698519b..244de92c56 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
@@ -30,7 +30,6 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.Iterator;
@@ -1201,7 +1200,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter());
Object result = converter.convertIfNecessary(matchingBeans.values(), type);
if (getDependencyComparator() != null && result instanceof List) {
- Collections.sort((List>) result, adaptDependencyComparator(matchingBeans));
+ ((List>) result).sort(adaptDependencyComparator(matchingBeans));
}
return result;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java
index 55ac70efdf..afc3f03906 100644
--- a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java
+++ b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-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.
@@ -17,7 +17,6 @@
package org.springframework.beans.support;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -135,7 +134,7 @@ public class PropertyComparator implements Comparator {
*/
public static void sort(List> source, SortDefinition sortDefinition) throws BeansException {
if (StringUtils.hasText(sortDefinition.getProperty())) {
- Collections.sort(source, new PropertyComparator<>(sortDefinition));
+ source.sort(new PropertyComparator<>(sortDefinition));
}
}
diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
index b6d9f9049c..046889c47e 100644
--- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
+++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
@@ -540,7 +540,7 @@ class ConfigurationClassParser {
return;
}
- Collections.sort(deferredImports, DEFERRED_IMPORT_COMPARATOR);
+ deferredImports.sort(DEFERRED_IMPORT_COMPARATOR);
for (DeferredImportSelectorHolder deferredImport : deferredImports) {
ConfigurationClass configClass = deferredImport.getConfigurationClass();
try {
diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
index 6a2f9538ff..38713f4e24 100644
--- a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
+++ b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
@@ -365,7 +365,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
if (logger.isInfoEnabled()) {
logger.info("Stopping beans in phase " + this.phase);
}
- Collections.sort(this.members, Collections.reverseOrder());
+ this.members.sort(Collections.reverseOrder());
CountDownLatch latch = new CountDownLatch(this.smartMemberCount);
Set countDownBeanNames = Collections.synchronizedSet(new LinkedHashSet<>());
for (LifecycleGroupMember member : this.members) {
diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java
index 00f7e3d409..a316814ed2 100644
--- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java
+++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-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.
@@ -260,7 +260,7 @@ class PostProcessorRegistrationDelegate {
if (comparatorToUse == null) {
comparatorToUse = OrderComparator.INSTANCE;
}
- Collections.sort(postProcessors, comparatorToUse);
+ postProcessors.sort(comparatorToUse);
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java b/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java
index 6bcf98d05b..f24653571c 100644
--- a/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java
+++ b/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-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.
@@ -18,7 +18,6 @@ package org.springframework.core;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -88,9 +87,8 @@ public class ExceptionDepthComparator implements Comparator> handledExceptions =
- new ArrayList<>(exceptionTypes);
- Collections.sort(handledExceptions, new ExceptionDepthComparator(targetException));
+ List> handledExceptions = new ArrayList<>(exceptionTypes);
+ handledExceptions.sort(new ExceptionDepthComparator(targetException));
return handledExceptions.get(0);
}
diff --git a/spring-core/src/main/java/org/springframework/core/OrderComparator.java b/spring-core/src/main/java/org/springframework/core/OrderComparator.java
index d2852bd9d0..513e631481 100644
--- a/spring-core/src/main/java/org/springframework/core/OrderComparator.java
+++ b/spring-core/src/main/java/org/springframework/core/OrderComparator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-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.
@@ -17,7 +17,6 @@
package org.springframework.core;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -43,7 +42,7 @@ import org.springframework.util.ObjectUtils;
* @since 07.04.2003
* @see Ordered
* @see org.springframework.core.annotation.AnnotationAwareOrderComparator
- * @see java.util.Collections#sort(java.util.List, java.util.Comparator)
+ * @see java.util.List#sort(java.util.Comparator)
* @see java.util.Arrays#sort(Object[], java.util.Comparator)
*/
public class OrderComparator implements Comparator