Skip to content

Commit cd0bb96

Browse files
committed
Fix Potential NPE in TomcatMetricsBinder.findContext()
Closes gh-27576
1 parent a4bf490 commit cd0bb96

File tree

1 file changed

+4
-2
lines changed
  • spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/tomcat

1 file changed

+4
-2
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/tomcat/TomcatMetricsBinder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,7 +69,9 @@ private Manager findManager(ApplicationContext applicationContext) {
6969
WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer();
7070
if (webServer instanceof TomcatWebServer) {
7171
Context context = findContext((TomcatWebServer) webServer);
72-
return context.getManager();
72+
if (context != null) {
73+
return context.getManager();
74+
}
7375
}
7476
}
7577
return null;

0 commit comments

Comments
 (0)