tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51872] request.getRemoteAddr() sometimes returning IP address from the previous request
Date Fri, 23 Sep 2011 08:09:32 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51872

--- Comment #8 from Mark Thomas <markt@apache.org> 2011-09-23 08:09:32 UTC ---
Looking at this again this morning, if the problem is in a Valve
RECYCLE_FACADES won't help since Valves have direct access to the Request
object rather than using the Facade.

The patch below can be used to see if a Valve (or similar) is accessing the
request after it has been recycled. In addition to logging an error, it can
either return null or throw an exception if this happens. Just comment out the
one you don't want.


Index: java/org/apache/catalina/connector/Request.java
===================================================================
--- java/org/apache/catalina/connector/Request.java    (revision 1174344)
+++ java/org/apache/catalina/connector/Request.java    (working copy)
@@ -508,7 +508,8 @@
         }

         mappingData.recycle();
-
+        remoteAddr = null;
+        
         if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
             if (facade != null) {
                 facade.clear();
@@ -1263,6 +1264,12 @@
      */
     @Override
     public String getRemoteAddr() {
+        if (mappingData.host == null) {
+            String msg = "Access to Request at invalid point in lifecycle";
+            log.error(msg);
+            // throw new IllegalStateException(msg);
+            return null;
+        }
         if (remoteAddr == null) {
             coyoteRequest.action
                 (ActionCode.REQ_HOST_ADDR_ATTRIBUTE, coyoteRequest);

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


Mime
View raw message