mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
This commit is contained in:
parent
7b79029949
commit
5157a75119
@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -52,15 +51,13 @@ class CompositeHandlerExceptionResolver implements HandlerExceptionResolver {
|
||||
if (this.resolvers == null) {
|
||||
this.resolvers = extractResolvers();
|
||||
}
|
||||
Optional<ModelAndView> modelAndView = this.resolvers.stream()
|
||||
ModelAndView resolved = this.resolvers.stream()
|
||||
.map((resolver) -> resolver.resolveException(request, response, handler, ex)).filter(Objects::nonNull)
|
||||
.findFirst();
|
||||
modelAndView.ifPresent((mav) -> {
|
||||
if (mav.isEmpty()) {
|
||||
request.setAttribute("javax.servlet.error.exception", ex);
|
||||
}
|
||||
});
|
||||
return modelAndView.orElse(null);
|
||||
.findFirst().orElse(null);
|
||||
if (resolved != null && resolved.isEmpty()) {
|
||||
request.setAttribute("javax.servlet.error.exception", ex);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
private List<HandlerExceptionResolver> extractResolvers() {
|
||||
|
@ -120,7 +120,7 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, ?> getResponseBody(ClientResponse response) {
|
||||
return (Map<String, ?>) response.bodyToMono(Map.class).block();
|
||||
return response.bodyToMono(Map.class).block();
|
||||
}
|
||||
|
||||
@Endpoint(id = "fail")
|
||||
|
Loading…
Reference in New Issue
Block a user