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

remm 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 c736449  Avoid using local host name when not needed
c736449 is described below

commit c736449509a6eeb656ad54ba1926a5d58f74bbc9
Author: remm <r...@apache.org>
AuthorDate: Thu May 20 16:13:34 2021 +0200

    Avoid using local host name when not needed
    
    BZ65301
---
 java/org/apache/catalina/valves/RemoteIpValve.java | 6 ++++--
 webapps/docs/changelog.xml                         | 4 ++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/RemoteIpValve.java 
b/java/org/apache/catalina/valves/RemoteIpValve.java
index 2497b01..0dbd186 100644
--- a/java/org/apache/catalina/valves/RemoteIpValve.java
+++ b/java/org/apache/catalina/valves/RemoteIpValve.java
@@ -609,7 +609,7 @@ public class RemoteIpValve extends ValveBase {
         final String originalScheme = request.getScheme();
         final boolean originalSecure = request.isSecure();
         final String originalServerName = request.getServerName();
-        final String originalLocalName = request.getLocalName();
+        final String originalLocalName = isChangeLocalName() ? 
request.getLocalName() : null;
         final int originalServerPort = request.getServerPort();
         final int originalLocalPort = request.getLocalPort();
         final String originalProxiesHeader = request.getHeader(proxiesHeader);
@@ -768,7 +768,9 @@ public class RemoteIpValve extends ValveBase {
             request.setSecure(originalSecure);
             request.getCoyoteRequest().scheme().setString(originalScheme);
             
request.getCoyoteRequest().serverName().setString(originalServerName);
-            
request.getCoyoteRequest().localName().setString(originalLocalName);
+            if (isChangeLocalName()) {
+                
request.getCoyoteRequest().localName().setString(originalLocalName);
+            }
             request.setServerPort(originalServerPort);
             request.setLocalPort(originalLocalPort);
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8f8304c..c07a701 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -108,6 +108,10 @@
   <subsection name="Catalina">
     <changelog>
       <fix>
+        <bug>65301</bug>: <code>RemoteIpValve</code> will now avoid getting
+        the local host name when it is not needed. (remm)
+      </fix>
+      <fix>
         <bug>65308</bug>: NPE in JNDIRealm when no 
<code>userRoleAttribute</code>
         is given. (fschumacher)
       </fix>

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

Reply via email to