You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/03/08 13:36:27 UTC

DO NOT REPLY [Bug 27514] New: - Environment variables mapped through the JkEnvVar (mod_jk 1.2) are present in the request.getAttribute(xxx) but not in request.getAttributeNames().

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27514>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27514

Environment variables mapped through the JkEnvVar (mod_jk 1.2) are present in the request.getAttribute(xxx) but not in request.getAttributeNames().

           Summary: Environment variables mapped through the JkEnvVar
                    (mod_jk 1.2) are present in the
                    request.getAttribute(xxx) but not in
                    request.getAttributeNames().
           Product: Tomcat 5
           Version: 5.0.19
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Connector:Coyote
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: remus@nolimits.ro


Environment variables mapped through the JkEnvVar (mod_jk 1.2) are present in 
the request.getAttribute(xxx) but not in request.getAttributeNames(). 
 
As it turns out in 
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteRequest.java 
getAttribute method is properly implemented but in the getAttributeNames the 
attributes comming from the coyoteRequest are not taken into consideration 
(the same might happen in Tomcat 4 too, didn't tested) 
 
I made a patch to correct the behavior, however not being very familiar with 
the tomcat sources the patch corrects the above described behavior but might 
not be in line with your way of doing things so feel free to adjust on it. 
 
Best regards, 
	Remus 
 
--- CoyoteRequest.java	2004-02-14 12:26:50.000000000 +0200 
+++ CoyoteRequest.java	2004-03-08 14:17:13.661831128 +0200 
@@ -163,6 +163,7 @@ 
      */ 
     public void setCoyoteRequest(Request coyoteRequest) { 
         this.coyoteRequest = coyoteRequest; 
+        if(coyoteRequest.getAttributes().size() == 0) copyOriginalAttributes 
= false;		 
         inputBuffer.setRequest(coyoteRequest); 
     } 
  
@@ -403,6 +404,14 @@ 
      */  
     protected Log log=null; 
      
+ 
+    /** 
+    * We can have attributes comming from JK (JkEnvVar) so before serving 
them 
+    * trough getAttributeNames we have to be sure that the local attributes  
+    * contains the ones from the coyoteRequest. 
+    */ 
+    protected boolean copyOriginalAttributes = true; 
+ 
     // --------------------------------------------------------- Public 
Methods 
  
     /** 
@@ -436,6 +445,7 @@ 
         localName = null; 
  
         attributes.clear(); 
+        copyOriginalAttributes = true; 
         notes.clear(); 
         cookies = null; 
  
@@ -990,6 +1000,7 @@ 
         if (isSecure()) { 
             getAttribute(Globals.CERTIFICATES_ATTR); 
         } 
+        if( copyOriginalAttributes) 
attributes.putAll(coyoteRequest.getAttributes()); 
         return new Enumerator(attributes.keySet(), true); 
     }

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