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(
	at org.springframework.boot.actuate.metrics.web.servlet.LongTaskTimingHandlerInterceptor.afterCompletion(
	at org.springframework.web.servlet.HandlerExecutionChain.triggerAfterCompletion(
	at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletion(

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.


Related questions

Dependency resolution fails with Gradle 5.3.x to 5.6.x hot 4
Controller annotated with @Timed and active TimedAspect clashes with WebMvcMetricsFilter hot 2
ConfigurationProperties with constructor binding cannot be mocked hot 2
NoClassDefFoundError: net/bytebuddy/NamingStrategy$SuffixingRandom$BaseNameResolver hot 2
Deadlock between BackgroundPreinitializer and main thread in Spring Cloud Config Server hot 2
spring boot Servlet.service() for servlet [dispatcherServlet] in context with path threw exception hot 2
Migrating OAuth2 from Spring Boot 1.5 to 2.0 Broken hot 2
Add AutoConfiguration support for spring-security-saml2-service-provider hot 2
Replace deprecated MediaType.APPLICATION_JSON_UTF8 usage hot 2
Classloading problems with Spring Boot, JDK11 and Security Manager hot 1
java.lang.NullPointerException: null occurs in HttpExchangeTracer hot 1
Multiple data source projects cannot be started hot 1
get error messag Could not fetch the SequenceInformation from the database, hibernate_sequence doesn't exist hot 1
HttpTraceFilter bean missing hot 1
A java.lang.NoClassDefFoundError: ch/qos/logback/classic/spi/ThrowableProxy was thrown when killing my app hot 1
Github User Rank List