Ask questionsActuator: NPE in LongTaskTimingHandlerInterceptor
I encountered the following NPE in Spring Boot Actuator 2.1.3.RELEASE:
java.lang.NullPointerException: null at org.springframework.boot.actuate.metrics.web.servlet.LongTaskTimingHandlerInterceptor.stopLongTaskTimers(LongTaskTimingHandlerInterceptor.java:123) at org.springframework.boot.actuate.metrics.web.servlet.LongTaskTimingHandlerInterceptor.afterCompletion(LongTaskTimingHandlerInterceptor.java:78) at org.springframework.web.servlet.HandlerExecutionChain.triggerAfterCompletion(HandlerExecutionChain.java:174) at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletion(DispatcherServlet.java:1424) …
I believe the assumption is that
LongTaskTimingContext#get(HttpServletRequest) never returns
null. However, it appears that there can be a case where the request does not contain the required attribute.
I think the code should check for null to be safe.
Answer questions MenschNestor
I can confirm that the issue disappears when I set the
unloadDelay to an appropriate value (longer than the sleep in the example). I had previously assumed that the sleep would be interrupted which would have made the request finish as well.