Prefer List.sort(Comparator) over Collections.sort(List, Comparator)

This commit is contained in:
Juergen Hoeller
2018-02-16 10:23:18 +01:00
parent b35274f5a7
commit 8d3264f680
25 changed files with 71 additions and 96 deletions

View File

@@ -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.
@@ -168,7 +168,7 @@ public class DestinationPatternsMessageCondition
return null;
}
Collections.sort(matches, this.pathMatcher.getPatternComparator(destination));
matches.sort(this.pathMatcher.getPatternComparator(destination));
return new DestinationPatternsMessageCondition(matches, this.pathMatcher);
}

View File

@@ -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.
@@ -18,7 +18,6 @@ package org.springframework.messaging.handler.invocation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -126,7 +125,7 @@ public abstract class AbstractExceptionHandlerMethodResolver {
}
}
if (!matches.isEmpty()) {
Collections.sort(matches, new ExceptionDepthComparator(exceptionType));
matches.sort(new ExceptionDepthComparator(exceptionType));
return this.mappedMethods.get(matches.get(0));
}
else {

View File

@@ -453,7 +453,7 @@ public abstract class AbstractMethodMessageHandler<T>
return;
}
Comparator<Match> comparator = new MatchComparator(getMappingComparator(message));
Collections.sort(matches, comparator);
matches.sort(comparator);
if (logger.isTraceEnabled()) {
logger.trace("Found " + matches.size() + " handler methods: " + matches);