Adapt to deprecation of NestedServletException

This commit is contained in:
Stephane Nicoll
2022-06-14 16:38:39 +02:00
parent 6894f561ce
commit b0f5fb51fc
7 changed files with 20 additions and 26 deletions

View File

@@ -40,7 +40,6 @@ import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.util.NestedServletException;
/**
* Intercepts incoming HTTP requests handled by Spring MVC handlers and records metrics
@@ -104,13 +103,13 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
}
catch (Exception ex) {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
record(timingContext, request, response, unwrapNestedServletException(ex));
record(timingContext, request, response, unwrapServletException(ex));
throw ex;
}
}
private Throwable unwrapNestedServletException(Throwable ex) {
return (ex instanceof NestedServletException) ? ex.getCause() : ex;
private Throwable unwrapServletException(Throwable ex) {
return (ex instanceof ServletException) ? ex.getCause() : ex;
}
private TimingContext startAndAttachTimingContext(HttpServletRequest request) {