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:
committed by
Oleg Zhurakousky
parent
66009830fd
commit
c6e4d1aaf6
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user