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

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

commit 619aab7c353beb5cecdad31c31097187e2f1eb35
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 20 06:48:35 2022 +0100

    Refactor for cleaner code and to avoid NPE warnings from IDE
---
 java/org/apache/catalina/connector/Response.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 032225b5c5..6d22590cb6 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1367,18 +1367,17 @@ public class Response implements HttpServletResponse {
             // If no ROOT context is defined, the context can be null.
             // In this case, the default Tomcat values are assumed, but without
             // reference to org.apache.catalina.STRICT_SERVLET_COMPLIANCE.
-            boolean reqHasContext = (context != null);
             String locationUri;
             // Relative redirects require HTTP/1.1
             if (getRequest().getCoyoteRequest().getSupportsRelativeRedirects() 
&&
-                    (!reqHasContext || context.getUseRelativeRedirects())) {
+                    (context == null || context.getUseRelativeRedirects())) {
                 locationUri = location;
             } else {
                 locationUri = toAbsolute(location);
             }
             setStatus(status);
             setHeader("Location", locationUri);
-            if (reqHasContext && context.getSendRedirectBody()) {
+            if (context != null && context.getSendRedirectBody()) {
                 PrintWriter writer = getWriter();
                 writer.print(sm.getString("coyoteResponse.sendRedirect.note",
                         Escape.htmlElementContent(locationUri)));


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

Reply via email to