Avoid unnecessary sorting in base ExceptionHandlerMethodResolvers

This commit is contained in:
Sam Brannen
2021-01-11 12:40:22 +01:00
parent b587a16d46
commit 570bdbd253
2 changed files with 8 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.1
*/
public class ExceptionHandlerMethodResolver {
@@ -179,7 +180,9 @@ public class ExceptionHandlerMethodResolver {
}
}
if (!matches.isEmpty()) {
matches.sort(new ExceptionDepthComparator(exceptionType));
if (matches.size() > 1) {
matches.sort(new ExceptionDepthComparator(exceptionType));
}
return this.mappedMethods.get(matches.get(0));
}
else {