Author: jochen Date: Fri May 12 15:48:37 2006 New Revision: 405921 URL: http://svn.apache.org/viewcvs?rev=405921&view=rev Log: Eliminated a possible endless loop in the WebServer. Avoiding a NoSuchElementException in the WebServer when the request was closed. Submitted-By: Elizabeth Fong, [EMAIL PROTECTED]
Modified: webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/changes.xml webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/src/java/org/apache/xmlrpc/WebServer.java Modified: webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/changes.xml URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/changes.xml?rev=405921&r1=405920&r2=405921&view=diff ============================================================================== --- webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/changes.xml (original) +++ webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/changes.xml Fri May 12 15:48:37 2006 @@ -22,6 +22,12 @@ Added the TimingOutCallback, which allows to abort a request, if the server doesn't reply within a given time. </action> + <action dev="jochen" type="fix" due-to="Elizabeth Fong" + due-to-email="[EMAIL PROTECTED]"> + Eliminated a possible endless loop in the WebServer. Avoiding + a NoSuchElementException in the WebServer when the request + was closed. + </action> </release> <release version="2.0.1" date="28-Dec-2005"> <action dev="jochen" type="fix" issue="XMLRPC-68" Modified: webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/src/java/org/apache/xmlrpc/WebServer.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/src/java/org/apache/xmlrpc/WebServer.java?rev=405921&r1=405920&r2=405921&view=diff ============================================================================== --- webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/src/java/org/apache/xmlrpc/WebServer.java (original) +++ webservices/xmlrpc/branches/XMLRPC_2_0_BRANCH/src/java/org/apache/xmlrpc/WebServer.java Fri May 12 15:48:37 2006 @@ -19,6 +19,7 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.EOFException; import java.io.IOException; import java.io.InterruptedIOException; import java.io.UnsupportedEncodingException; @@ -31,6 +32,7 @@ import java.util.Stack; import java.util.StringTokenizer; import java.util.Vector; + import org.apache.commons.codec.binary.Base64; /** @@ -719,8 +721,12 @@ // tokenize first line of HTTP request StringTokenizer tokens = new StringTokenizer(line); + if (!tokens.hasMoreElements()) + { + continue; + } String method = tokens.nextToken(); - String uri = tokens.nextToken(); + tokens.nextToken(); // Discard the URI String httpVersion = tokens.nextToken(); keepAlive = XmlRpc.getKeepAlive() && HTTP_11.equals(httpVersion); @@ -776,6 +782,10 @@ } while (keepAlive); } + catch (EOFException ignore) + { + // Ignore me + } catch (Exception exception) { if (XmlRpc.debug) @@ -818,6 +828,10 @@ for (;;) { next = input.read(); + if (count == 0 && next < 0) + { + throw new EOFException("Connection closed"); + } if (next < 0 || next == '\n') { break;