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

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


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

commit 58e1d3fed6d23ab0113bac5a848f85a3a2a0df14
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 5f3f331..234492b 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 2365c9b..46de0ac 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -52,6 +52,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

Reply via email to