mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Avoid NPE when binder is closed before started event
Previously, if TomcatMetricsBinder destroy() was called before it had received an ApplicationStartedEvent an NPE would be thrown due to TomcatMetrics being null. This NPE was then caught and logged at warning level by the disposable bean adapter. This prevents the NPE by checking that the TomcatMetrics instance is null before calling close() on it. See gh-22141
This commit is contained in:
parent
9c732fa2b6
commit
b34c268547
@ -86,7 +86,9 @@ public class TomcatMetricsBinder implements ApplicationListener<ApplicationStart
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.tomcatMetrics.close();
|
||||
if (null != this.tomcatMetrics) {
|
||||
this.tomcatMetrics.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user