Author: remy.maucherat(a)jboss.com
Date: 2008-03-27 20:52:58 -0400 (Thu, 27 Mar 2008)
New Revision: 561
Modified:
trunk/java/org/apache/tomcat/util/collections/MultiMap.java
trunk/java/org/apache/tomcat/util/http/Parameters.java
Log:
- Fix problems in the MultiMap algorithm.
Modified: trunk/java/org/apache/tomcat/util/collections/MultiMap.java
===================================================================
--- trunk/java/org/apache/tomcat/util/collections/MultiMap.java 2008-03-27 21:13:09 UTC
(rev 560)
+++ trunk/java/org/apache/tomcat/util/collections/MultiMap.java 2008-03-28 00:52:58 UTC
(rev 561)
@@ -195,21 +195,21 @@
}
public int findNext( int startPos ) {
- int next= fields[startPos].nextPos;
- if( next != MultiMap.NEED_NEXT ) {
- return next;
- }
+ int next= fields[startPos].nextPos;
+ if( next != MultiMap.NEED_NEXT ) {
+ return next;
+ }
- // next==NEED_NEXT, we never searched for this header
- MessageBytes name=fields[startPos].name;
- for (int i = startPos; i < count; i++) {
- if (fields[i].name.equals(name)) {
- // cache the search result
- fields[startPos].nextPos=i;
- return i;
- }
- }
- fields[startPos].nextPos= MultiMap.LAST;
+ // next==NEED_NEXT, we never searched for this header
+ MessageBytes name=fields[startPos].name;
+ for (int i = (startPos + 1); i < count; i++) {
+ if (fields[i].name.equals(name)) {
+ // cache the search result
+ fields[startPos].nextPos=i;
+ return i;
+ }
+ }
+ fields[startPos].nextPos= MultiMap.LAST;
return -1;
}
@@ -219,8 +219,8 @@
// -------------------- Internal representation --------------------
final class Field {
- MessageBytes name;
- MessageBytes value;
+ MessageBytes name = MessageBytes.newInstance();
+ MessageBytes value = MessageBytes.newInstance();
// Extra info for speed
Modified: trunk/java/org/apache/tomcat/util/http/Parameters.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/Parameters.java 2008-03-27 21:13:09 UTC (rev
560)
+++ trunk/java/org/apache/tomcat/util/http/Parameters.java 2008-03-28 00:52:58 UTC (rev
561)
@@ -107,9 +107,9 @@
public String[] getParameterValues(String name) {
handleQueryParameters();
int pos = findFirst(name);
- if (pos > 0) {
+ if (pos >= 0) {
ArrayList<String> result = new ArrayList<String>();
- while (pos > 0) {
+ while (pos >= 0) {
result.add(getValue(pos).toString());
pos = findNext(pos);
}
@@ -128,7 +128,7 @@
public String getParameter(String name) {
handleQueryParameters();
int pos = findFirst(name);
- if (pos > 0) {
+ if (pos >= 0) {
return getValue(pos).toString();
} else {
return null;
Show replies by date