All, I was reading-through the request-parameters processing code and I noticed that while the Parameters class is used to build a Map of parameter names -> value arrays, that same Map is not used when Request.getParameterNames is called.
Instead, Request.getParameterNames builds a copy of that same Map and returns it: public Map<String, String[]> getParameterMap() { if (parameterMap.isLocked()) { return parameterMap; } Enumeration<String> enumeration = getParameterNames(); while (enumeration.hasMoreElements()) { String name = enumeration.nextElement(); String[] values = getParameterValues(name); parameterMap.put(name, values); } parameterMap.setLocked(true); return parameterMap; } Is there any particular reason not to return the internal Map from the Parameters class? Spec says that the Map should be immutable, but that can be easily done in a number of ways. Is the map being defensively-copied so that the client code can't destroy the internal representation? That's the only reason I can think of for this behavior. I was just thinking that the "copy" technique of course requires twice the memory (and a bit of CPU time for the copy) for request parameters in any request that calls any of the getParameter* family of calls. I don't have any performance data but I'm wondering if anyone might want to be able to disable this defensive-copy perhaps in a trusted environment to squeeze a bit more performance out of their server. Any comments? I'm not suggesting a patch just yet... just wondering if anyone has any thoughts on the subject. Thanks, -chris
signature.asc
Description: OpenPGP digital signature