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

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


The following commit(s) were added to refs/heads/main by this push:
     new e6a121916f TOMEE-4375 - Fix NPEs in SavedRequest (#1328)
e6a121916f is described below

commit e6a121916f49da4d3f37b058704f72c19c7e3a76
Author: mpuening <[email protected]>
AuthorDate: Mon Aug 5 12:42:16 2024 -0400

    TOMEE-4375 - Fix NPEs in SavedRequest (#1328)
    
    * Fix NPEs in SavedRequest
    
    * Fix NPEs in SavedRequest
    
    * Fix NPEs in SavedRequest
---
 .../java/org/apache/tomee/security/http/SavedRequest.java  | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/SavedRequest.java
 
b/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/SavedRequest.java
index f760d94f6d..2461014be8 100644
--- 
a/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/SavedRequest.java
+++ 
b/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/SavedRequest.java
@@ -97,17 +97,25 @@ public class SavedRequest implements Serializable {
 
             @Override
             public Enumeration<String> getHeaderNames() {
-                return Collections.enumeration(headers.keySet());
+                return headers != null ? 
Collections.enumeration(headers.keySet()) : Collections.emptyEnumeration();
             }
 
             @Override
             public Enumeration<String> getHeaders(String name) {
-                return Collections.enumeration(headers.get(name));
+                List<String> header = headers != null ? headers.get(name) : 
null;
+                if (header == null) {
+                    header = Collections.emptyList();
+                }
+                return Collections.enumeration(header);
             }
 
             @Override
             public String getHeader(String name) {
-                return headers.get(name).get(0);
+                List<String> header = headers != null ? headers.get(name) : 
null;
+                if (header == null || header.isEmpty()) {
+                    return null;
+                }
+                return header.get(0);
             }
 
             @Override

Reply via email to