Bug 47364 - HttpServletRequest.getAttributeNames() does not return the names of all attributes
HttpServletRequest.getAttributeNames() does not return the names of all attri...
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
6.0.20
PC Windows XP
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-06-12 13:44 UTC by Chris Markle
Modified: 2009-11-01 10:39 UTC (History)
0 users



Attachments
Original email exchange on this issue (4.44 KB, text/plain)
2009-06-12 13:45 UTC, Chris Markle
Details
Patch that adds internal attributes but breaks TCK tests (4.59 KB, patch)
2009-11-01 10:20 UTC, Mark Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Markle 2009-06-12 13:44:21 UTC
In an email exchange that involved Ranier (see attachment), he suggested I log this in Bugzilla, so I am.

I was using Tomcat 6.0.20 on Windows XP SP3 with the latest Java 6 JVM. In the doGet method of a servlet, I was trying to see all request attributes to see if the "sendfile supported" attribute was set (specifically the request attribute org.apache.tomcat.sendfile.support). On my first pass at this I just used HttpServletRequest.getAttributeNames() to dump all the names of the attributes expecting to see this one listed, but I got no attributes listed at all. Then I actually got the attribute via getAttribute("org.apache.tomcat.sendfile.support") which worked. So getAttributeNames is not returning the names of all attributes.

So either:

1. getAttributeNames needs to be fixed to return the names of all attributes (i.e., a code change); or

2. The Tomcat doc needs to be updated in some way as to say thatgetAttributeNames only returns certain attributes and blah blah (i.e., a doc change).

Again my original email and Ranier's reply is attached.

Thanks!
Comment 1 Chris Markle 2009-06-12 13:45:33 UTC
Created attachment 23806 [details]
Original email exchange on this issue
Comment 2 Mark Thomas 2009-11-01 10:20:36 UTC
Created attachment 24451 [details]
Patch that adds internal attributes but breaks TCK tests

I looked at just including all the Tomcat internal attributes in the return from getAttributeNames() but this causes problems with the Servlet 2.5 TCK tests which expect that getAttributeNames() return only those attributes that have been set via setAttribute().

Therefore it looks like the doc change is the way I'll have to go. For completeness the patch I tried that returned all the attribute names is attached so you can patch Tomcat locally if you particularly need that functionality. I thought about making this a configurable option but I didn't want to add the complexity for something that I couldn't see causing any problems that can't be easily worked around by an app that needed to.
Comment 3 Mark Thomas 2009-11-01 10:39:08 UTC
Trunk and 6.0.x now have updated Javadoc. Thsi will be included in 6.0.21 onwards.