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

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


The following commit(s) were added to refs/heads/main by this push:
     new e3ebf33c51 Avoid possible NPEs - review from lihan
e3ebf33c51 is described below

commit e3ebf33c51f02f4c534f3f0a9e125c28fcca8c00
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 5 13:33:29 2023 +0100

    Avoid possible NPEs - review from lihan
---
 java/org/apache/catalina/connector/Connector.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/Connector.java 
b/java/org/apache/catalina/connector/Connector.java
index dac7fdd642..1c06a724f2 100644
--- a/java/org/apache/catalina/connector/Connector.java
+++ b/java/org/apache/catalina/connector/Connector.java
@@ -1033,13 +1033,14 @@ public class Connector extends LifecycleMBeanBase {
         setState(LifecycleState.STARTING);
 
         // Configure the utility executor before starting the protocol handler
-        if (service != null) {
+        if (protocolHandler != null && service != null) {
             
protocolHandler.setUtilityExecutor(service.getServer().getUtilityExecutor());
         }
 
         try {
             protocolHandler.start();
         } catch (Exception e) {
+            // Includes NPE - protocolHandler will be null for invalid 
protocol if throwOnFailure is false
             throw new 
LifecycleException(sm.getString("coyoteConnector.protocolHandlerStartFailed"), 
e);
         }
     }
@@ -1064,7 +1065,7 @@ public class Connector extends LifecycleMBeanBase {
         }
 
         // Remove the utility executor once the protocol handler has been 
stopped
-        if (service != null) {
+        if (protocolHandler != null) {
             protocolHandler.setUtilityExecutor(null);
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to