You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2009/03/10 20:52:14 UTC
svn commit: r752233 - in /httpcomponents/httpcore/trunk: ./
httpcore/src/main/java/org/apache/http/impl/io/
httpcore/src/test/java/org/apache/http/impl/io/
httpcore/src/test/java/org/apache/http/mockup/
Author: olegk
Date: Tue Mar 10 19:52:13 2009
New Revision: 752233
URL: http://svn.apache.org/viewvc?rev=752233&view=rev
Log:
HTTPCORE-191: Blocking HTTP connections are now capable of correctly preserving their internal state on SocketTimeoutExceptions, which makes it possible to continue reading from the connection after a socket timeout.
Added:
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
Modified:
httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.java
httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/mockup/TimeoutByteArrayInputStream.java
Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=752233&r1=752232&r2=752233&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Tue Mar 10 19:52:13 2009
@@ -1,6 +1,11 @@
Changes since 4.0
-------------------
+* [HTTPCORE-191] Blocking HTTP connections are now capable of correctly preserving their internal
+ state on SocketTimeoutExceptions, which makes it possible to continue reading from the connection
+ after a socket timeout.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCORE-190] ChunkedInputStream is now capable of correctly preserving its internal state on
SocketTimeoutExceptions, which makes it possible to continue reading from the stream after a
socket timeout.
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java?rev=752233&r1=752232&r2=752233&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java Tue Mar 10 19:52:13 2009
@@ -33,6 +33,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
import org.apache.http.Header;
import org.apache.http.HttpException;
@@ -55,11 +56,17 @@
*/
public abstract class AbstractMessageParser implements HttpMessageParser {
+ private static final int HEAD_LINE = 0;
+ private static final int HEADERS = 1;
+
private final SessionInputBuffer sessionBuffer;
private final int maxHeaderCount;
private final int maxLineLen;
+ private final List headerLines;
protected final LineParser lineParser;
+ private int state;
+ private HttpMessage message;
/**
* Creates an instance of this class.
@@ -99,6 +106,8 @@
this.maxLineLen = params.getIntParameter(
CoreConnectionPNames.MAX_LINE_LENGTH, -1);
this.lineParser = (parser != null) ? parser : BasicLineParser.DEFAULT;
+ this.headerLines = new ArrayList();
+ this.state = HEAD_LINE;
}
/**
@@ -114,6 +123,8 @@
* including the continuation lines. Setting this parameter to a negative
* value or zero will disable the check.
* @return array of HTTP headers
+ * @param parser line parser to use. Can be <code>null</code>, in which case
+ * the default implementation of this interface will be used.
*
* @throws IOException in case of an I/O error
* @throws HttpException in case of HTTP protocol violation
@@ -124,14 +135,52 @@
int maxLineLen,
LineParser parser)
throws HttpException, IOException {
+ if (parser == null) {
+ parser = BasicLineParser.DEFAULT;
+ }
+ List headerLines = new ArrayList();
+ return parseHeaders(inbuffer, maxHeaderCount, maxLineLen, parser, headerLines);
+ }
+
+ /**
+ * Parses HTTP headers from the data receiver stream according to the generic
+ * format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
+ *
+ * @param inbuffer Session input buffer
+ * @param maxHeaderCount maximum number of headers allowed. If the number
+ * of headers received from the data stream exceeds maxCount value, an
+ * IOException will be thrown. Setting this parameter to a negative value
+ * or zero will disable the check.
+ * @param maxLineLen maximum number of characters for a header line,
+ * including the continuation lines. Setting this parameter to a negative
+ * value or zero will disable the check.
+ * @param parser line parser to use.
+ * @param headerLines List of header lines. This list will be used to store
+ * intermediate results. This makes it possible to resume parsing of
+ * headers in case of a {@link java.io.InterruptedIOException}.
+ *
+ * @return array of HTTP headers
+ *
+ * @throws IOException in case of an I/O error
+ * @throws HttpException in case of HTTP protocol violation
+ */
+ public static Header[] parseHeaders(
+ final SessionInputBuffer inbuffer,
+ int maxHeaderCount,
+ int maxLineLen,
+ final LineParser parser,
+ final List headerLines)
+ throws HttpException, IOException {
if (inbuffer == null) {
throw new IllegalArgumentException("Session input buffer may not be null");
}
- if (parser == null)
- parser = BasicLineParser.DEFAULT;
-
- ArrayList headerLines = new ArrayList();
+ if (parser == null) {
+ throw new IllegalArgumentException("Line parser may not be null");
+ }
+ if (headerLines == null) {
+ throw new IllegalArgumentException("Header line list may not be null");
+ }
CharArrayBuffer current = null;
CharArrayBuffer previous = null;
@@ -205,19 +254,31 @@
throws IOException, HttpException, ParseException;
public HttpMessage parse() throws IOException, HttpException {
- HttpMessage message = null;
- try {
- message = parseHead(this.sessionBuffer);
- } catch (ParseException px) {
- throw new ProtocolException(px.getMessage(), px);
- }
- Header[] headers = AbstractMessageParser.parseHeaders(
- this.sessionBuffer,
- this.maxHeaderCount,
- this.maxLineLen,
- this.lineParser);
- message.setHeaders(headers);
- return message;
+ int st = this.state;
+ switch (st) {
+ case HEAD_LINE:
+ try {
+ this.message = parseHead(this.sessionBuffer);
+ } catch (ParseException px) {
+ throw new ProtocolException(px.getMessage(), px);
+ }
+ this.state = HEADERS;
+ case HEADERS:
+ Header[] headers = AbstractMessageParser.parseHeaders(
+ this.sessionBuffer,
+ this.maxHeaderCount,
+ this.maxLineLen,
+ this.lineParser,
+ this.headerLines);
+ this.message.setHeaders(headers);
+ HttpMessage result = this.message;
+ this.message = null;
+ this.headerLines.clear();
+ this.state = HEAD_LINE;
+ return result;
+ default:
+ throw new IllegalStateException("Inconsistent parser state");
+ }
}
}
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java?rev=752233&r1=752232&r2=752233&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java Tue Mar 10 19:52:13 2009
@@ -33,8 +33,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InterruptedIOException;
import java.io.OutputStream;
-import java.net.SocketTimeoutException;
import org.apache.http.Header;
import org.apache.http.MalformedChunkCodingException;
@@ -450,7 +450,7 @@
if (i > 0) {
bytesRead += i;
}
- } catch (SocketTimeoutException ex) {
+ } catch (InterruptedIOException ex) {
timeouts++;
}
}
@@ -476,7 +476,7 @@
if (i > 0) {
bytesRead += i;
}
- } catch (SocketTimeoutException ex) {
+ } catch (InterruptedIOException ex) {
timeouts++;
}
}
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.java?rev=752233&r1=752232&r2=752233&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.java Tue Mar 10 19:52:13 2009
@@ -46,8 +46,7 @@
import junit.framework.TestSuite;
/**
- * Unit tests for {@link Header}.
- *
+ * Unit tests for {@link AbstractMessageParser}.
*/
public class TestMessageParser extends TestCase {
Added: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java?rev=752233&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java Tue Mar 10 19:52:13 2009
@@ -0,0 +1,188 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.io;
+
+import java.io.InterruptedIOException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.http.ConnectionClosedException;
+import org.apache.http.Header;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpVersion;
+import org.apache.http.RequestLine;
+import org.apache.http.impl.DefaultHttpRequestFactory;
+import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.mockup.SessionInputBufferMockup;
+import org.apache.http.mockup.TimeoutByteArrayInputStream;
+import org.apache.http.params.BasicHttpParams;
+
+/**
+ * Unit tests for {@link HttpRequestParser}.
+ */
+public class TestRequestParser extends TestCase {
+
+ public TestRequestParser(String testName) {
+ super(testName);
+ }
+
+ public static void main(String args[]) {
+ String[] testCaseName = { TestRequestParser.class.getName() };
+ junit.textui.TestRunner.main(testCaseName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestRequestParser.class);
+ }
+
+ public void testInvalidConstructorInput() throws Exception {
+ try {
+ new HttpRequestParser(
+ null,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpRequestFactory(),
+ new BasicHttpParams());
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ try {
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
+ new HttpRequestParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ null,
+ new BasicHttpParams());
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ try {
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
+ new HttpRequestParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpRequestFactory(),
+ null);
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
+ public void testBasicMessageParsing() throws Exception {
+ String s =
+ "GET / HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "User-Agent: whatever\r\n" +
+ "Cookie: c1=stuff\r\n" +
+ "\r\n";
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII");
+
+ HttpRequestParser parser = new HttpRequestParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpRequestFactory(),
+ new BasicHttpParams());
+
+ HttpRequest httprequest = (HttpRequest) parser.parse();
+
+ RequestLine reqline = httprequest.getRequestLine();
+ assertNotNull(reqline);
+ assertEquals("GET", reqline.getMethod());
+ assertEquals("/", reqline.getUri());
+ assertEquals(HttpVersion.HTTP_1_1, reqline.getProtocolVersion());
+ Header[] headers = httprequest.getAllHeaders();
+ assertEquals(3, headers.length);
+ }
+
+ public void testConnectionClosedException() throws Exception {
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
+
+ HttpRequestParser parser = new HttpRequestParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpRequestFactory(),
+ new BasicHttpParams());
+
+ try {
+ parser.parse();
+ fail("ConnectionClosedException should have been thrown");
+ } catch (ConnectionClosedException expected) {
+ }
+ }
+
+ public void testMessageParsingTimeout() throws Exception {
+ String s =
+ "GET \000/ HTTP/1.1\r\000\n" +
+ "Host: loca\000lhost\r\n" +
+ "User-Agent: whatever\r\n" +
+ "Coo\000kie: c1=stuff\r\n" +
+ "\000\r\n";
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(
+ new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);
+
+ HttpRequestParser parser = new HttpRequestParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpRequestFactory(),
+ new BasicHttpParams());
+
+ int timeoutCount = 0;
+
+ HttpRequest httprequest = null;
+ for (int i = 0; i < 10; i++) {
+ try {
+ httprequest = (HttpRequest) parser.parse();
+ break;
+ } catch (InterruptedIOException ex) {
+ timeoutCount++;
+ }
+
+ }
+ assertNotNull(httprequest);
+ assertEquals(5, timeoutCount);
+
+ RequestLine reqline = httprequest.getRequestLine();
+ assertNotNull(reqline);
+ assertEquals("GET", reqline.getMethod());
+ assertEquals("/", reqline.getUri());
+ assertEquals(HttpVersion.HTTP_1_1, reqline.getProtocolVersion());
+ Header[] headers = httprequest.getAllHeaders();
+ assertEquals(3, headers.length);
+ }
+
+}
+
Added: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java?rev=752233&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java Tue Mar 10 19:52:13 2009
@@ -0,0 +1,188 @@
+/*
+ * $HeadURL:$
+ * $Revision:$
+ * $Date:$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.io;
+
+import java.io.InterruptedIOException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.NoHttpResponseException;
+import org.apache.http.StatusLine;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.mockup.SessionInputBufferMockup;
+import org.apache.http.mockup.TimeoutByteArrayInputStream;
+import org.apache.http.params.BasicHttpParams;
+
+/**
+ * Unit tests for {@link HttpResponseParser}.
+ */
+public class TestResponseParser extends TestCase {
+
+ public TestResponseParser(String testName) {
+ super(testName);
+ }
+
+ public static void main(String args[]) {
+ String[] testCaseName = { TestResponseParser.class.getName() };
+ junit.textui.TestRunner.main(testCaseName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestResponseParser.class);
+ }
+
+ public void testInvalidConstructorInput() throws Exception {
+ try {
+ new HttpResponseParser(
+ null,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpResponseFactory(),
+ new BasicHttpParams());
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ try {
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
+ new HttpResponseParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ null,
+ new BasicHttpParams());
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ try {
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
+ new HttpResponseParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpResponseFactory(),
+ null);
+ fail("IllegalArgumentException should have been thrown");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
+ public void testBasicMessageParsing() throws Exception {
+ String s =
+ "HTTP/1.1 200 OK\r\n" +
+ "Server: whatever\r\n" +
+ "Date: some date\r\n" +
+ "Set-Cookie: c1=stuff\r\n" +
+ "\r\n";
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII");
+
+ HttpResponseParser parser = new HttpResponseParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpResponseFactory(),
+ new BasicHttpParams());
+
+ HttpResponse httpresponse = (HttpResponse) parser.parse();
+
+ StatusLine statusline = httpresponse.getStatusLine();
+ assertNotNull(statusline);
+ assertEquals(200, statusline.getStatusCode());
+ assertEquals("OK", statusline.getReasonPhrase());
+ assertEquals(HttpVersion.HTTP_1_1, statusline.getProtocolVersion());
+ Header[] headers = httpresponse.getAllHeaders();
+ assertEquals(3, headers.length);
+ }
+
+ public void testConnectionClosedException() throws Exception {
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
+
+ HttpResponseParser parser = new HttpResponseParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpResponseFactory(),
+ new BasicHttpParams());
+
+ try {
+ parser.parse();
+ fail("NoHttpResponseException should have been thrown");
+ } catch (NoHttpResponseException expected) {
+ }
+ }
+
+ public void testMessageParsingTimeout() throws Exception {
+ String s =
+ "HTTP\000/1.1 200\000 OK\r\n" +
+ "Server: wha\000tever\r\n" +
+ "Date: some date\r\n" +
+ "Set-Coo\000kie: c1=stuff\r\n" +
+ "\000\r\n";
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(
+ new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);
+
+ HttpResponseParser parser = new HttpResponseParser(
+ inbuffer,
+ BasicLineParser.DEFAULT,
+ new DefaultHttpResponseFactory(),
+ new BasicHttpParams());
+
+ int timeoutCount = 0;
+
+ HttpResponse httpresponse = null;
+ for (int i = 0; i < 10; i++) {
+ try {
+ httpresponse = (HttpResponse) parser.parse();
+ break;
+ } catch (InterruptedIOException ex) {
+ timeoutCount++;
+ }
+
+ }
+ assertNotNull(httpresponse);
+ assertEquals(5, timeoutCount);
+
+ StatusLine statusline = httpresponse.getStatusLine();
+ assertNotNull(statusline);
+ assertEquals(200, statusline.getStatusCode());
+ assertEquals("OK", statusline.getReasonPhrase());
+ assertEquals(HttpVersion.HTTP_1_1, statusline.getProtocolVersion());
+ Header[] headers = httpresponse.getAllHeaders();
+ assertEquals(3, headers.length);
+ }
+
+}
+
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/mockup/TimeoutByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/mockup/TimeoutByteArrayInputStream.java?rev=752233&r1=752232&r2=752233&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/mockup/TimeoutByteArrayInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/mockup/TimeoutByteArrayInputStream.java Tue Mar 10 19:52:13 2009
@@ -33,7 +33,7 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.SocketTimeoutException;
+import java.io.InterruptedIOException;
/**
* Test class similar to {@link ByteArrayInputStream} that throws if encounters
@@ -65,7 +65,7 @@
if (v != 0) {
return v;
} else {
- throw new SocketTimeoutException("Timeout");
+ throw new InterruptedIOException("Timeout");
}
}
@@ -87,7 +87,7 @@
}
if ((this.buf[this.pos] & 0xff) == 0) {
this.pos++;
- throw new SocketTimeoutException("Timeout");
+ throw new InterruptedIOException("Timeout");
}
for (int i = 0; i < len; i++) {
int v = this.buf[this.pos] & 0xff;