diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/tomcat/TomcatMetricsBinder.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/tomcat/TomcatMetricsBinder.java index 689c41cdca..688692ff79 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/tomcat/TomcatMetricsBinder.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/tomcat/TomcatMetricsBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.apache.catalina.Container; import org.apache.catalina.Context; import org.apache.catalina.Manager; +import org.springframework.beans.factory.DisposableBean; import org.springframework.boot.context.event.ApplicationStartedEvent; import org.springframework.boot.web.context.WebServerApplicationContext; import org.springframework.boot.web.embedded.tomcat.TomcatWebServer; @@ -38,12 +39,14 @@ import org.springframework.context.ApplicationListener; * @author Andy Wilkinson * @since 2.1.0 */ -public class TomcatMetricsBinder implements ApplicationListener { +public class TomcatMetricsBinder implements ApplicationListener, DisposableBean { private final MeterRegistry meterRegistry; private final Iterable tags; + private volatile TomcatMetrics tomcatMetrics; + public TomcatMetricsBinder(MeterRegistry meterRegistry) { this(meterRegistry, Collections.emptyList()); } @@ -57,7 +60,8 @@ public class TomcatMetricsBinder implements ApplicationListener