[tomcat] branch master updated: Fix potential NPE in some embedding scenarios.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[tomcat] branch master updated: Fix potential NPE in some embedding scenarios.

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

The following commit(s) were added to refs/heads/master by this push:
     new e469527  Fix potential NPE in some embedding scenarios.
e469527 is described below

commit e469527d8da572b0483b485d7ed8cd1b998497ba
Author: Mark Thomas <[hidden email]>
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 f6f2132..0cacd3f 100644
--- a/java/org/apache/catalina/core/NamingContextListener.java
+++ b/java/org/apache/catalina/core/NamingContextListener.java
@@ -1102,7 +1102,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 4e28e49..3b19889 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -61,6 +61,11 @@
         <code>Host</code> is configured with an <code>xmlBase</code>. Patch
         provided by uk4sx. (markt)
+      <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>
   <subsection name="Coyote">

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]