This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push: new 07270ed Fix potential NPE in some embedding scenarios. 07270ed is described below commit 07270ed6e9bd04fdea5b0aeb5330021c66023899 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Sep 11 18:17:04 2019 +0100 Fix potential NPE in some embedding scenarios. When embedding a Service directly and JNDI is enabled there is no Server --- java/org/apache/catalina/core/NamingContextListener.java | 6 +++++- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java/org/apache/catalina/core/NamingContextListener.java b/java/org/apache/catalina/core/NamingContextListener.java index 8bbfce8..0b99d55 100644 --- a/java/org/apache/catalina/core/NamingContextListener.java +++ b/java/org/apache/catalina/core/NamingContextListener.java @@ -1113,7 +1113,11 @@ public class NamingContextListener private javax.naming.Context getGlobalNamingContext() { if (container instanceof Context) { Engine e = (Engine) ((Context) container).getParent().getParent(); - return e.getService().getServer().getGlobalNamingContext(); + Server s = e.getService().getServer(); + // When the Service is an embedded Service, there is no Server + if (s != null) { + return s.getGlobalNamingContext(); + } } return null; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 1f94919..6d8c54a 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -98,6 +98,11 @@ <code>RealmBase.hasRole()</code> for given security constraints. (michaelo) </fix> + <fix> + Avoid a potential <code>NullPointerException</code> on Service stop if a + Service is embedded directly (i.e. with no Server) in an applciation + and JNDI is enabled. Patch provided by S. Ali Tokmen. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org