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

remm 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 57fe88cd58 Fix possible NPEs
57fe88cd58 is described below

commit 57fe88cd580a7dede5b16ab32262e081246bfc09
Author: remm <[email protected]>
AuthorDate: Tue Sep 12 16:45:23 2023 +0200

    Fix possible NPEs
    
    Found by coverity.
---
 .../org/apache/catalina/startup/ContextConfig.java | 37 ++++++++++++++--------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/catalina/startup/ContextConfig.java 
b/java/org/apache/catalina/startup/ContextConfig.java
index 55c4707c64..ffba96d9b3 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -601,8 +601,11 @@ public class ContextConfig implements LifecycleListener {
                         
ConfigFileLoader.getSource().getResource(defaultContextXml)) {
                     if (generateCode) {
                         contextXmlJavaSource = 
getContextXmlJavaSource(contextXmlPackageName, contextXmlSimpleClassName);
-                        digester.startGeneratingCode();
-                        generateClassHeader(digester, contextXmlPackageName, 
contextXmlSimpleClassName);
+                        if (contextXmlJavaSource != null) {
+                            digester.startGeneratingCode();
+                            generateClassHeader(digester, 
contextXmlPackageName, contextXmlSimpleClassName);
+                            generateCode = false;
+                        }
                     }
                     URL defaultContextUrl = 
contextXmlResource.getURI().toURL();
                     processContextConfig(digester, defaultContextUrl, 
contextXmlResource.getInputStream());
@@ -2197,19 +2200,25 @@ public class ContextConfig implements LifecycleListener 
{
     protected void processAnnotationsInParallel(Set<WebXml> fragments, boolean 
handlesTypesOnly,
                                                 Map<String, 
JavaClassCacheEntry> javaClassCache) {
         Server s = getServer();
-        ExecutorService pool = null;
-        pool = s.getUtilityExecutor();
-        List<Future<?>> futures = new ArrayList<>(fragments.size());
-        for (WebXml fragment : fragments) {
-            Runnable task = new AnnotationScanTask(fragment, handlesTypesOnly, 
javaClassCache);
-            futures.add(pool.submit(task));
-        }
-        try {
-            for (Future<?> future : futures) {
-                future.get();
+        ExecutorService pool = (s == null) ? null : s.getUtilityExecutor();
+        if (pool != null) {
+            List<Future<?>> futures = new ArrayList<>(fragments.size());
+            for (WebXml fragment : fragments) {
+                Runnable task = new AnnotationScanTask(fragment, 
handlesTypesOnly, javaClassCache);
+                futures.add(pool.submit(task));
+            }
+            try {
+                for (Future<?> future : futures) {
+                    future.get();
+                }
+            } catch (Exception e) {
+                throw new 
RuntimeException(sm.getString("contextConfig.processAnnotationsInParallelFailure"),
 e);
+            }
+        } else {
+            // Fallback to regular processing
+            for (WebXml fragment : fragments) {
+                scanWebXmlFragment(handlesTypesOnly, fragment, javaClassCache);
             }
-        } catch (Exception e) {
-            throw new 
RuntimeException(sm.getString("contextConfig.processAnnotationsInParallelFailure"),
 e);
         }
     }
 


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

Reply via email to