Fix possible NPE in FunctionHandlerMapping

Resolves #233

Happens when HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTES is null
Can be seen when using spring-boot-starter-actuator with a scanned function
The path is null because the request wrapped by the WebMvcMetricsFilter is unmodifiable,
so setting the attribute in AbstractHandlerMethodMapping#handleMatch has no effect
This commit is contained in:
Filip Hrisafov
2018-11-17 13:13:00 +01:00
committed by Oleg Zhurakousky
parent 66009830fd
commit c6e4d1aaf6

View File

@@ -83,15 +83,15 @@ public class FunctionHandlerMapping extends RequestMappingHandlerMapping
}
String path = (String) request
.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
if (path == null) {
return handler;
}
if (StringUtils.hasText(prefix) && !path.startsWith(prefix)) {
return null;
}
if (path.startsWith(prefix)) {
path = path.substring(prefix.length());
}
if (path == null) {
return handler;
}
Object function = findFunctionForGet(request, path);
if (function != null) {
if (logger.isDebugEnabled()) {