remm 2004/02/11 04:09:29 Modified: catalina/src/share/org/apache/catalina/core ApplicationHttpRequest.java Log: - Bug 26838: refactor once again the enum algorithm. - Delegate special getAttribute only if we're not in a forward. Revision Changes Path 1.18 +30 -9 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationHttpRequest.java Index: ApplicationHttpRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationHttpRequest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ApplicationHttpRequest.java 2 Feb 2004 19:38:39 -0000 1.17 +++ ApplicationHttpRequest.java 11 Feb 2004 12:09:29 -0000 1.18 @@ -71,6 +71,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; import javax.servlet.RequestDispatcher; import javax.servlet.http.HttpServletRequest; @@ -265,7 +266,8 @@ if (pos == -1) { return getRequest().getAttribute(name); } else { - if ((specialAttributes[pos] == null) && (pos >= 5)) { + if ((specialAttributes[pos] == null) + && (specialAttributes[5] == null) && (pos >= 5)) { // If it's a forward special attribute, and null, it means this // is an include, so we check the wrapped request since // the request could have been forwarded before the include @@ -881,30 +883,49 @@ protected int pos = -1; protected int last = -1; protected Enumeration parentEnumeration = null; + protected String next = null; public AttributeNamesEnumerator() { parentEnumeration = getRequest().getAttributeNames(); for (int i = 0; i < specialAttributes.length; i++) { - if (specialAttributes[i] != null) { + if (getAttribute(specials[i]) != null) { last = i; } } } public boolean hasMoreElements() { - return ((pos != last) || (parentEnumeration.hasMoreElements())); + return ((pos != last) || (next != null) + || ((next = findNext()) != null)); } public Object nextElement() { if (pos != last) { for (int i = pos + 1; i <= last; i++) { - if (specialAttributes[i] != null) { + if (getAttribute(specials[i]) != null) { pos = i; return (specials[i]); } } } - return parentEnumeration.nextElement(); + String result = next; + if (next != null) { + next = findNext(); + } else { + throw new NoSuchElementException(); + } + return result; + } + + protected String findNext() { + String result = null; + while ((result == null) && (parentEnumeration.hasMoreElements())) { + String current = (String) parentEnumeration.nextElement(); + if (!isSpecial(current)) { + result = current; + } + } + return result; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]