Java 8: Collections.sort() can be replaced with List.sort()

This commit is contained in:
Lars Grefer 2019-08-09 00:49:26 +02:00 committed by Rob Winch
parent 25c06be1eb
commit 3a5d8ba696
5 changed files with 5 additions and 5 deletions

View File

@ -134,7 +134,7 @@ public abstract class SecurityConfigurerAdapter<O, B extends SecurityBuilder<O>>
private boolean addObjectPostProcessor( private boolean addObjectPostProcessor(
ObjectPostProcessor<? extends Object> objectPostProcessor) { ObjectPostProcessor<? extends Object> objectPostProcessor) {
boolean result = this.postProcessors.add(objectPostProcessor); boolean result = this.postProcessors.add(objectPostProcessor);
Collections.sort(postProcessors, AnnotationAwareOrderComparator.INSTANCE); postProcessors.sort(AnnotationAwareOrderComparator.INSTANCE);
return result; return result;
} }
} }

View File

@ -129,7 +129,7 @@ public class AuthenticationConfiguration {
@Autowired(required = false) @Autowired(required = false)
public void setGlobalAuthenticationConfigurers( public void setGlobalAuthenticationConfigurers(
List<GlobalAuthenticationConfigurerAdapter> configurers) throws Exception { List<GlobalAuthenticationConfigurerAdapter> configurers) throws Exception {
Collections.sort(configurers, AnnotationAwareOrderComparator.INSTANCE); configurers.sort(AnnotationAwareOrderComparator.INSTANCE);
this.globalAuthConfigurers = configurers; this.globalAuthConfigurers = configurers;
} }

View File

@ -2327,7 +2327,7 @@ public final class HttpSecurity extends
@Override @Override
protected DefaultSecurityFilterChain performBuild() throws Exception { protected DefaultSecurityFilterChain performBuild() throws Exception {
Collections.sort(filters, comparator); filters.sort(comparator);
return new DefaultSecurityFilterChain(requestMatcher, filters); return new DefaultSecurityFilterChain(requestMatcher, filters);
} }

View File

@ -139,7 +139,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
webSecurity.debug(debugEnabled); webSecurity.debug(debugEnabled);
} }
Collections.sort(webSecurityConfigurers, AnnotationAwareOrderComparator.INSTANCE); webSecurityConfigurers.sort(AnnotationAwareOrderComparator.INSTANCE);
Integer previousOrder = null; Integer previousOrder = null;
Object previousConfig = null; Object previousConfig = null;

View File

@ -164,7 +164,7 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
unorderedFilterChain.addAll(authBldr.getFilters()); unorderedFilterChain.addAll(authBldr.getFilters());
unorderedFilterChain.addAll(buildCustomFilterList(element, pc)); unorderedFilterChain.addAll(buildCustomFilterList(element, pc));
Collections.sort(unorderedFilterChain, new OrderComparator()); unorderedFilterChain.sort(new OrderComparator());
checkFilterChainOrder(unorderedFilterChain, pc, pc.extractSource(element)); checkFilterChainOrder(unorderedFilterChain, pc, pc.extractSource(element));
// The list of filter beans // The list of filter beans