diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java index 68d008e76a..4ee674b58c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java @@ -18,6 +18,7 @@ package org.springframework.web.reactive.result.method; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -28,6 +29,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Function; +import java.util.stream.Collectors; import reactor.core.publisher.Mono; @@ -202,7 +205,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap Map methods = MethodIntrospector.selectMethods(userType, (MethodIntrospector.MetadataLookup) method -> getMappingForMethod(method, userType)); if (logger.isTraceEnabled()) { - logger.trace("Mapped " + methods.size() + " handler method(s) for " + userType + ": " + methods); + logger.trace(formatMappings(userType, methods)); } methods.forEach((key, mapping) -> { Method invocableMethod = AopUtils.selectInvocableMethod(key, userType); @@ -211,6 +214,24 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap } } + private String formatMappings(Class userType, Map methods) { + + String formattedType = Arrays.stream(userType.getPackage().getName().split("\\.")) + .map(p -> p.substring(0, 1)) + .collect(Collectors.joining(".", "", ".")) + userType.getSimpleName(); + + Function methodFormatter = method -> Arrays.stream(method.getParameterTypes()) + .map(Class::getSimpleName) + .collect(Collectors.joining(",", "(", ")")); + + return methods.entrySet().stream() + .map(e -> { + Method method = e.getKey(); + return e.getValue() + ": " + method.getName() + methodFormatter.apply(method); + }) + .collect(Collectors.joining("\n\t", "\n\t" + formattedType + ":" + "\n\t", "")); + } + /** * Register a handler method and its unique mapping. Invoked at startup for * each detected handler method. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java index d43b34f69d..ced76769f3 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfo.java @@ -18,6 +18,7 @@ package org.springframework.web.reactive.result.method; import java.util.Arrays; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import org.springframework.lang.Nullable; @@ -307,24 +308,28 @@ public final class RequestMappingInfo implements RequestCondition extends AbstractHandlerMap } }); if (logger.isTraceEnabled()) { - logger.trace("Mapped " + methods.size() + " handler method(s) for " + userType + ": " + methods); + logger.trace(formatMappings(userType, methods)); } methods.forEach((method, mapping) -> { Method invocableMethod = AopUtils.selectInvocableMethod(method, userType); @@ -281,6 +284,24 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap } } + private String formatMappings(Class userType, Map methods) { + + String formattedType = Arrays.stream(userType.getPackage().getName().split("\\.")) + .map(p -> p.substring(0, 1)) + .collect(Collectors.joining(".", "", ".")) + userType.getSimpleName(); + + Function methodFormatter = method -> Arrays.stream(method.getParameterTypes()) + .map(Class::getSimpleName) + .collect(Collectors.joining(",", "(", ")")); + + return methods.entrySet().stream() + .map(e -> { + Method method = e.getKey(); + return e.getValue() + ": " + method.getName() + methodFormatter.apply(method); + }) + .collect(Collectors.joining("\n\t", "\n\t" + formattedType + ":" + "\n\t", "")); + } + /** * Register a handler method and its unique mapping. Invoked at startup for * each detected handler method. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java index a3085386cd..29a1d63825 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java @@ -17,6 +17,7 @@ package org.springframework.web.servlet.mvc.method; import java.util.List; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.springframework.http.HttpMethod; @@ -316,24 +317,28 @@ public final class RequestMappingInfo implements RequestCondition