Index: java/org/apache/commons/httpclient/ChunkedInputStream.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java,v retrieving revision 1.17 diff -u -r1.17 ChunkedInputStream.java --- java/org/apache/commons/httpclient/ChunkedInputStream.java 13 Jul 2003 13:54:50 -0000 1.17 +++ java/org/apache/commons/httpclient/ChunkedInputStream.java 15 Jul 2003 14:15:19 -0000 @@ -327,7 +327,12 @@ * @throws IOException If an IO problem occurs */ private void parseTrailerHeaders() throws IOException { - Header[] footers = HttpParser.parseHeaders(in); + Header[] footers = null; + try { + footers = HttpParser.parseHeaders(in); + } catch(HttpException e) { + throw new IOException(e.getMessage()); + } for (int i = 0; i < footers.length; i++) { method.addResponseFooter(footers[i]); Index: java/org/apache/commons/httpclient/HttpClient.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v retrieving revision 1.78 diff -u -r1.78 HttpClient.java --- java/org/apache/commons/httpclient/HttpClient.java 5 Jul 2003 22:31:20 -0000 1.78 +++ java/org/apache/commons/httpclient/HttpClient.java 15 Jul 2003 14:15:19 -0000 @@ -370,7 +370,7 @@ HttpConnectionManager connmanager = this.httpConnectionManager; - HttpConnection connection = connmanager.getConnection( + HttpConnection connection = connmanager.getConnectionWithTimeout( methodConfiguration, httpConnectionTimeout ); Index: java/org/apache/commons/httpclient/HttpConnection.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v retrieving revision 1.68 diff -u -r1.68 HttpConnection.java --- java/org/apache/commons/httpclient/HttpConnection.java 5 Jul 2003 22:31:20 -0000 1.68 +++ java/org/apache/commons/httpclient/HttpConnection.java 15 Jul 2003 14:15:21 -0000 @@ -1207,7 +1207,9 @@ // keep the original value of used, as it will be set to false by close(). boolean tempUsed = used; HttpConnection.this.close(); - if (tempUsed) { + if (ioe instanceof InterruptedIOException) { + return new IOTimeoutException(ioe.getMessage()); + } else if (tempUsed) { LOG.debug( "Output exception occurred on a used connection. Will treat as recoverable.", ioe Index: java/org/apache/commons/httpclient/HttpConnectionManager.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java,v retrieving revision 1.15 diff -u -r1.15 HttpConnectionManager.java --- java/org/apache/commons/httpclient/HttpConnectionManager.java 28 Jan 2003 04:40:20 -0000 1.15 +++ java/org/apache/commons/httpclient/HttpConnectionManager.java 15 Jul 2003 14:15:21 -0000 @@ -69,8 +69,9 @@ * @see org.apache.commons.httpclient.HttpConnection * @see org.apache.commons.httpclient.HttpClient#HttpClient(HttpConnectionManager) * - * @author Unascribed + * @author Michael Becke * @author Mike Bowler + * @author Oleg Kalnichevski * * @since 2.0 */ @@ -111,9 +112,34 @@ * timeout expires * * @see HttpConnection#setHttpConnectionManager(HttpConnectionManager) + * + * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long) */ HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) throws HttpException; + + /** + * Gets an HttpConnection for a given host configuration. If a connection is + * not available, this method will block for at most the specified number of + * milliseconds or until a connection becomes available. + * + * The connection manager should be registered with any HttpConnection that + * is created. + * + * @param hostConfiguration the host configuration to use to configure the + * connection + * @param timeout - the time (in milliseconds) to wait for a connection to + * become available, 0 to specify an infinite timeout + * + * @return an HttpConnection for the given configuraiton + * + * @throws ConnectTimeoutException if no connection becomes available before the + * timeout expires + * + * @see HttpConnection#setHttpConnectionManager(HttpConnectionManager) + */ + HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) + throws ConnectTimeoutException; /** * Releases the given HttpConnection for use by other requests. Index: java/org/apache/commons/httpclient/HttpException.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpException.java,v retrieving revision 1.14 diff -u -r1.14 HttpException.java --- java/org/apache/commons/httpclient/HttpException.java 15 Jul 2003 02:19:58 -0000 1.14 +++ java/org/apache/commons/httpclient/HttpException.java 15 Jul 2003 14:15:21 -0000 @@ -63,7 +63,6 @@ package org.apache.commons.httpclient; -import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.lang.reflect.Method; @@ -86,7 +85,7 @@ * @author Unascribed * @version $Revision: 1.14 $ $Date: 2003/07/15 02:19:58 $ */ -public class HttpException extends IOException { +public class HttpException extends Exception { /** * Creates a new HttpException with a null detail message. Index: java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.168 diff -u -r1.168 HttpMethodBase.java --- java/org/apache/commons/httpclient/HttpMethodBase.java 15 Jul 2003 12:46:32 -0000 1.168 +++ java/org/apache/commons/httpclient/HttpMethodBase.java 15 Jul 2003 14:15:24 -0000 @@ -954,11 +954,11 @@ private void checkExecuteConditions(HttpState state, HttpConnection conn) throws HttpException { - if (null == state) { - throw new NullPointerException("HttpState parameter"); + if (state == null) { + throw new IllegalArgumentException("HttpState parameter may not be null"); } - if (null == conn) { - throw new NullPointerException("HttpConnection parameter"); + if (conn == null) { + throw new IllegalArgumentException("HttpConnection parameter may not be null"); } if (hasBeenUsed()) { throw new IllegalStateException("Already used, but not recycled."); @@ -995,8 +995,7 @@ * @throws NullPointerException if the state is null */ public int execute(HttpState state, HttpConnection conn) - throws HttpException, HttpRecoverableException, - IOException, NullPointerException { + throws HttpException, HttpRecoverableException, IOException { LOG.trace("enter HttpMethodBase.execute(HttpState, HttpConnection)"); @@ -1062,7 +1061,7 @@ if (forwardCount >= MAX_FORWARDS) { LOG.error("Narrowly avoided an infinite loop in execute"); - throw new HttpRecoverableException("Maximum redirects (" + throw new ProtocolException("Maximum redirects (" + MAX_FORWARDS + ") exceeded"); } @@ -1185,19 +1184,12 @@ + " to " + newProtocol + " is not supported"); } - try { - String oldHost = currentUri.getHost(); - String newHost = redirectUri.getHost(); - if (!oldHost.equalsIgnoreCase(newHost)) { - // TODO: Add an HttpNotImplementedException or some such? - throw new ProtocolException("Redirect from host " + oldHost - + " to " + newHost + " is not supported"); - } - } catch (URIException e) { - LOG.warn("Error getting URI host", e); - throw new ProtocolException("Invalid Redirect URI from: " - + currentUri.getEscapedURI() + " to: " + redirectUri.getEscapedURI() - ); + String oldHost = currentUri.getHost(); + String newHost = redirectUri.getHost(); + if (!oldHost.equalsIgnoreCase(newHost)) { + // TODO: Add an HttpNotImplementedException or some such? + throw new ProtocolException("Redirect from host " + oldHost + + " to " + newHost + " is not supported"); } int oldPort = currentUri.getPort(); @@ -1867,31 +1859,27 @@ * @throws HttpException when a protocol or i/o error occurs or state is invalid */ protected void readResponse(HttpState state, HttpConnection conn) - throws HttpException { + throws IOException, HttpException { LOG.trace( - "enter HttpMethodBase.readResponse(HttpState, HttpConnection)"); - try { - // Status line & line may have already been received - // if 'expect - continue' handshake has been used - while (this.statusLine == null) { - readStatusLine(state, conn); - processStatusLine(state, conn); - readResponseHeaders(state, conn); - processResponseHeaders(state, conn); - - int status = this.statusLine.getStatusCode(); - if ((status >= 100) && (status < 200)) { - if (LOG.isInfoEnabled()) { - LOG.info("Discarding unexpected response: " + this.statusLine.toString()); - } - this.statusLine = null; + "enter HttpMethodBase.readResponse(HttpState, HttpConnection)"); + // Status line & line may have already been received + // if 'expect - continue' handshake has been used + while (this.statusLine == null) { + readStatusLine(state, conn); + processStatusLine(state, conn); + readResponseHeaders(state, conn); + processResponseHeaders(state, conn); + + int status = this.statusLine.getStatusCode(); + if ((status >= 100) && (status < 200)) { + if (LOG.isInfoEnabled()) { + LOG.info("Discarding unexpected response: " + this.statusLine.toString()); } + this.statusLine = null; } - readResponseBody(state, conn); - processResponseBody(state, conn); - } catch (IOException e) { - throw new HttpRecoverableException(e.toString()); } + readResponseBody(state, conn); + processResponseBody(state, conn); } /** @@ -1951,7 +1939,7 @@ * @throws IOException if an IO problem occurs. */ private InputStream readResponseBody(HttpConnection conn) - throws IOException { + throws HttpException, IOException { LOG.trace("enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)"); Index: java/org/apache/commons/httpclient/HttpRecoverableException.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpRecoverableException.java,v retrieving revision 1.8 diff -u -r1.8 HttpRecoverableException.java --- java/org/apache/commons/httpclient/HttpRecoverableException.java 15 Jul 2003 02:19:58 -0000 1.8 +++ java/org/apache/commons/httpclient/HttpRecoverableException.java 15 Jul 2003 14:15:26 -0000 @@ -63,6 +63,8 @@ package org.apache.commons.httpclient; +import java.io.IOException; + /** *
* Signals that an HTTP or HttpClient exception has occurred. This
@@ -73,7 +75,7 @@
* @author Unascribed
* @version $Revision: 1.8 $ $Date: 2003/07/15 02:19:58 $
*/
-public class HttpRecoverableException extends TransportException {
+public class HttpRecoverableException extends IOException {
/**
* Creates a new HttpRecoverableException with a null detail message.
Index: java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v
retrieving revision 1.19
diff -u -r1.19 MultiThreadedHttpConnectionManager.java
--- java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java 15 Jul 2003 02:19:58 -0000 1.19
+++ java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java 15 Jul 2003 14:15:27 -0000
@@ -182,8 +182,8 @@
while (true) {
try {
- return getConnection(hostConfiguration, 0);
- } catch (HttpException e) {
+ return getConnectionWithTimeout(hostConfiguration, 0);
+ } catch (ConnectTimeoutException e) {
// we'll go ahead and log this, but it should never happen. HttpExceptions
// are only thrown when the timeout occurs and since we have no timeout
// it should never happen.
@@ -196,12 +196,12 @@
}
/**
- * @see HttpConnectionManager#getConnection(HostConfiguration, long)
+ * @see HttpConnectionManager#getConnectionWithTimeout(HostConfiguration, long)
*/
- public HttpConnection getConnection(HostConfiguration hostConfiguration,
- long timeout) throws HttpException {
+ public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration,
+ long timeout) throws ConnectTimeoutException {
- LOG.trace("enter HttpConnectionManager.getConnection(HostConfiguration, long)");
+ LOG.trace("enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)");
if (hostConfiguration == null) {
throw new IllegalArgumentException("hostConfiguration is null");
@@ -219,6 +219,22 @@
return new HttpConnectionAdapter(conn);
}
+ /**
+ * @see HttpConnectionManager#getConnection(HostConfiguration, long)
+ *
+ * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long)
+ */
+ public HttpConnection getConnection(HostConfiguration hostConfiguration,
+ long timeout) throws HttpException {
+
+ LOG.trace("enter HttpConnectionManager.getConnection(HostConfiguration, long)");
+ try {
+ return getConnectionWithTimeout(hostConfiguration, timeout);
+ } catch(ConnectTimeoutException e) {
+ throw new HttpException(e.getMessage());
+ }
+ }
+
/**
* Gets a connection or waits if one is not available. A connection is
* available if one exists that is not being used or if fewer than
@@ -235,7 +251,7 @@
* 'timeout' milliseconds
*/
private HttpConnection doGetConnection(HostConfiguration hostConfiguration,
- long timeout) throws HttpException {
+ long timeout) throws ConnectTimeoutException {
HttpConnection connection = null;
Index: java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java,v
retrieving revision 1.12
diff -u -r1.12 SimpleHttpConnectionManager.java
--- java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java 12 May 2003 02:42:42 -0000 1.12
+++ java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java 15 Jul 2003 14:15:28 -0000
@@ -99,9 +99,9 @@
}
/**
- * @see HttpConnectionManager#getConnection(HostConfiguration, long)
+ * @see HttpConnectionManager#getConnectionWithTimeout(HostConfiguration, long)
*/
- public HttpConnection getConnection(
+ public HttpConnection getConnectionWithTimeout(
HostConfiguration hostConfiguration, long timeout) {
if (httpConnection == null) {
@@ -133,6 +133,16 @@
return httpConnection;
}
+
+ /**
+ * @see HttpConnectionManager#getConnection(HostConfiguration, long)
+ *
+ * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long)
+ */
+ public HttpConnection getConnection(
+ HostConfiguration hostConfiguration, long timeout) {
+ return getConnectionWithTimeout(hostConfiguration, timeout);
+ }
/**
* @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection)
Index: java/org/apache/commons/httpclient/TransportException.java
===================================================================
RCS file: java/org/apache/commons/httpclient/TransportException.java
diff -N java/org/apache/commons/httpclient/TransportException.java
--- java/org/apache/commons/httpclient/TransportException.java 15 Jul 2003 02:19:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-/*
- * $Header: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/TransportException.java,v 1.1 2003/07/15 02:19:58 mbecke Exp $
- * $Revision: 1.1 $
- * $Date: 2003/07/15 02:19:58 $
- *
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Commons", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * 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
- *
- * Why is it from IOException? - * To simplify the programming style for the inherited exception instances. - *
* * @author Sung-Gu + * @author Oleg Kalnichevski * @version $Revision: 1.8 $ $Date: 2002/03/14 15:14:01 */ -public class URIException extends IOException { +public class URIException extends HttpException { // ----------------------------------------------------------- constructors Index: java/org/apache/commons/httpclient/methods/HeadMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java,v retrieving revision 1.21 diff -u -r1.21 HeadMethod.java --- java/org/apache/commons/httpclient/methods/HeadMethod.java 15 Jul 2003 12:30:16 -0000 1.21 +++ java/org/apache/commons/httpclient/methods/HeadMethod.java 15 Jul 2003 14:15:28 -0000 @@ -66,6 +66,7 @@ import java.io.IOException; import org.apache.commons.httpclient.HttpConnection; +import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.ProtocolException; import org.apache.commons.httpclient.HttpState; @@ -164,7 +165,7 @@ * @since 2.0 */ protected void readResponseBody(HttpState state, HttpConnection conn) - throws IOException { + throws HttpException, IOException { LOG.trace( "enter HeadMethod.readResponseBody(HttpState, HttpConnection)"); Index: test/org/apache/commons/httpclient/TestGetMethodLocal.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestGetMethodLocal.java,v retrieving revision 1.10 diff -u -r1.10 TestGetMethodLocal.java --- test/org/apache/commons/httpclient/TestGetMethodLocal.java 5 Mar 2003 04:02:56 -0000 1.10 +++ test/org/apache/commons/httpclient/TestGetMethodLocal.java 15 Jul 2003 14:15:29 -0000 @@ -210,7 +210,7 @@ client.executeMethod(method2); assertEquals(0, method2.getRecoverableExceptionCount() ); } - catch (IOException ioe) { + catch (Exception ioe) { fail("Problem executing method : " + ioe.toString() ); } Index: test/org/apache/commons/httpclient/TestHttpConnectionManager.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java,v retrieving revision 1.8 diff -u -r1.8 TestHttpConnectionManager.java --- test/org/apache/commons/httpclient/TestHttpConnectionManager.java 28 Apr 2003 23:19:58 -0000 1.8 +++ test/org/apache/commons/httpclient/TestHttpConnectionManager.java 15 Jul 2003 14:15:30 -0000 @@ -128,7 +128,7 @@ HttpConnection connection = mgr.getConnection(hostConfiguration); ConnectMethod connect = new ConnectMethod(get); assertTrue(connect.execute(new HttpState(), connection) != 200); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); fail("Error executing connect: " + e); } @@ -136,8 +136,8 @@ // this should calling releaseConnection() releases the connection try { get.releaseConnection(); - mgr.getConnection(hostConfiguration, 1).releaseConnection(); - } catch (HttpException e1) { + mgr.getConnectionWithTimeout(hostConfiguration, 1).releaseConnection(); + } catch (Exception e1) { fail("Connection should have been available."); } @@ -147,7 +147,7 @@ HttpConnection connection = mgr.getConnection(hostConfiguration); ConnectMethod connect = new ConnectMethod(get); assertTrue(connect.execute(new HttpState(), connection) != 200); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); fail("Error executing connect: " + e); } @@ -155,8 +155,8 @@ // make sure reading the response fully releases the connection try { get.getResponseBodyAsString(); - mgr.getConnection(hostConfiguration, 1).releaseConnection(); - } catch (HttpException e1) { + mgr.getConnectionWithTimeout(hostConfiguration, 1).releaseConnection(); + } catch (ConnectTimeoutException e1) { fail("Connection should have been available."); } @@ -166,7 +166,7 @@ HttpConnection connection = mgr.getConnection(hostConfiguration); ConnectMethod connect = new ConnectMethod(get); assertTrue(connect.execute(new HttpState(), connection) != 200); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); fail("Error executing connect: " + e); } @@ -174,8 +174,8 @@ // make sure closing the output stream releases the connection try { get.getResponseBodyAsStream().close(); - mgr.getConnection(hostConfiguration, 1).releaseConnection(); - } catch (HttpException e) { + mgr.getConnectionWithTimeout(hostConfiguration, 1).releaseConnection(); + } catch (ConnectTimeoutException e) { fail("Connection should have been available."); } catch (IOException e) { e.printStackTrace(); @@ -238,7 +238,9 @@ // this should fail quickly since the connection has not been released client.executeMethod(getMethod); fail("a httpConnection should not be available"); - } catch (HttpException e) { + } catch (ConnectTimeoutException e) { + } catch (HttpException e) { + fail("error reading from server; " + e); } catch (IOException e) { fail("error reading from server; " + e); } @@ -319,8 +321,8 @@ try { // the connection from host1 should be reclaimed - connection = connectionManager.getConnection(host2, 100); - } catch (HttpException e) { + connection = connectionManager.getConnectionWithTimeout(host2, 100); + } catch (ConnectTimeoutException e) { e.printStackTrace(); fail("a httpConnection should have been available: " + e); } @@ -347,9 +349,9 @@ try { // this should fail quickly since the connection has not been released - connectionManager.getConnection(host2, 100); + connectionManager.getConnectionWithTimeout(host2, 100); fail("a httpConnection should not be available"); - } catch (HttpException e) { + } catch (ConnectTimeoutException e) { // this should throw an exception } @@ -359,8 +361,8 @@ try { // there should be a connection available now - connection2 = connectionManager.getConnection(host2, 100); - } catch (HttpException e) { + connection2 = connectionManager.getConnectionWithTimeout(host2, 100); + } catch (ConnectTimeoutException e) { e.printStackTrace(); fail("a httpConnection should have been available: " + e); } @@ -437,7 +439,9 @@ // this should fail quickly since the connection has not been released client.executeMethod(getMethod2); fail("a httpConnection should not be available"); + } catch (ConnectTimeoutException e) { } catch (HttpException e) { + fail("error reading from server; " + e); } catch (IOException e) { fail("error reading from server; " + e); } @@ -518,10 +522,10 @@ HttpConnection conn1 = mgr.getConnection(hostConfig); HttpConnection conn2 = mgr.getConnection(hostConfig); - HttpConnection conn3 = mgr.getConnection(hostConfig, 1000); + HttpConnection conn3 = mgr.getConnectionWithTimeout(hostConfig, 1000); fail("Expected an HttpException."); - }catch(HttpException e){ + }catch(ConnectTimeoutException e){ //Expected result } } @@ -545,8 +549,8 @@ public void run() { try { - connection = connectionManager.getConnection(hostConfiguration, timeout); - } catch (HttpException e) { + connection = connectionManager.getConnectionWithTimeout(hostConfiguration, timeout); + } catch (ConnectTimeoutException e) { } } Index: test/org/apache/commons/httpclient/TestMethodCharEncoding.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodCharEncoding.java,v retrieving revision 1.3 diff -u -r1.3 TestMethodCharEncoding.java --- test/org/apache/commons/httpclient/TestMethodCharEncoding.java 15 Jul 2003 12:46:33 -0000 1.3 +++ test/org/apache/commons/httpclient/TestMethodCharEncoding.java 15 Jul 2003 14:15:31 -0000 @@ -146,7 +146,7 @@ } - public void testResponseCharEncoding() throws IOException { + public void testResponseCharEncoding() throws Exception { SimpleHttpConnection conn = new SimpleHttpConnection(); String body = "stuff"; @@ -240,7 +240,7 @@ } - public void testQueryParams() throws IOException { + public void testQueryParams() throws Exception { GetMethod get = new GetMethod("/"); @@ -268,7 +268,7 @@ assertEquals(ch_msg, params.get("ch")); } - public void testUrlEncodedRequestBody() throws IOException { + public void testUrlEncodedRequestBody() throws Exception { PostMethod httppost = new PostMethod("/"); Index: test/org/apache/commons/httpclient/TestMethodsExternalHost.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodsExternalHost.java,v retrieving revision 1.10 diff -u -r1.10 TestMethodsExternalHost.java --- test/org/apache/commons/httpclient/TestMethodsExternalHost.java 5 Jul 2003 22:31:21 -0000 1.10 +++ test/org/apache/commons/httpclient/TestMethodsExternalHost.java 15 Jul 2003 14:15:31 -0000 @@ -216,8 +216,10 @@ try { client.executeMethod(method); if ((PROXY_HOST != null) && (method.getStatusCode() >= 400)) return; - } catch (IOException e) { + } catch (URIException e) { return; // IOException and HttpException are ok + } catch (HttpException e) { + } catch (IOException e) { } fail("Should have thrown an exception");