You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/07/16 22:48:28 UTC
cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestGetMethodLocal.java TestHttpConnectionManager.java TestMethodCharEncoding.java TestMethodsExternalHost.java
olegk 2003/07/16 13:48:28
Modified: httpclient/src/java/org/apache/commons/httpclient
ChunkedInputStream.java HttpClient.java
HttpConnection.java HttpConnectionManager.java
HttpMethodBase.java HttpRecoverableException.java
MultiThreadedHttpConnectionManager.java
SimpleHttpConnectionManager.java URIException.java
httpclient/src/java/org/apache/commons/httpclient/methods
HeadMethod.java
httpclient/src/test/org/apache/commons/httpclient
TestGetMethodLocal.java
TestHttpConnectionManager.java
TestMethodCharEncoding.java
TestMethodsExternalHost.java
Removed: httpclient/src/java/org/apache/commons/httpclient
TransportException.java
Log:
Bug fix #19868 (Exception handling in HttpClient requires redesign)
Further exception handling clean-up
Contributed by Oleg Kalnichevski
Reviewed by Michael Becke & Laura Werner
Revision Changes Path
1.18 +15 -4 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java
Index: ChunkedInputStream.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ChunkedInputStream.java 13 Jul 2003 13:54:50 -0000 1.17
+++ ChunkedInputStream.java 16 Jul 2003 20:48:27 -0000 1.18
@@ -67,6 +67,9 @@
import java.io.IOException;
import java.io.InputStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* <p>Transparently coalesces chunks of a HTTP stream that uses
@@ -112,6 +115,8 @@
/** The method that this stream came from */
private HttpMethod method;
+ /** Log object for this class. */
+ private static final Log LOG = LogFactory.getLog(ChunkedInputStream.class);
/**
*
*
@@ -327,7 +332,13 @@
* @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) {
+ LOG.error("Error parsing trailer headers", e);
+ throw new IOException(e.getMessage());
+ }
for (int i = 0; i < footers.length; i++) {
method.addResponseFooter(footers[i]);
1.79 +5 -5 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
Index: HttpClient.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- HttpClient.java 5 Jul 2003 22:31:20 -0000 1.78
+++ HttpClient.java 16 Jul 2003 20:48:27 -0000 1.79
@@ -370,7 +370,7 @@
HttpConnectionManager connmanager = this.httpConnectionManager;
- HttpConnection connection = connmanager.getConnection(
+ HttpConnection connection = connmanager.getConnectionWithTimeout(
methodConfiguration,
httpConnectionTimeout
);
1.69 +7 -5 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java
Index: HttpConnection.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- HttpConnection.java 5 Jul 2003 22:31:20 -0000 1.68
+++ HttpConnection.java 16 Jul 2003 20:48:27 -0000 1.69
@@ -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
1.16 +30 -4 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java
Index: HttpConnectionManager.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HttpConnectionManager.java 28 Jan 2003 04:40:20 -0000 1.15
+++ HttpConnectionManager.java 16 Jul 2003 20:48:27 -0000 1.16
@@ -69,8 +69,9 @@
* @see org.apache.commons.httpclient.HttpConnection
* @see org.apache.commons.httpclient.HttpClient#HttpClient(HttpConnectionManager)
*
- * @author Unascribed
+ * @author Michael Becke
* @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
+ * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
*
* @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.
1.169 +34 -46 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Index: HttpMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- HttpMethodBase.java 15 Jul 2003 12:46:32 -0000 1.168
+++ HttpMethodBase.java 16 Jul 2003 20:48:27 -0000 1.169
@@ -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)");
1.9 +7 -5 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpRecoverableException.java
Index: HttpRecoverableException.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpRecoverableException.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HttpRecoverableException.java 15 Jul 2003 02:19:58 -0000 1.8
+++ HttpRecoverableException.java 16 Jul 2003 20:48:27 -0000 1.9
@@ -63,6 +63,8 @@
package org.apache.commons.httpclient;
+import java.io.IOException;
+
/**
* <p>
* Signals that an HTTP or HttpClient exception has occurred. This
@@ -73,7 +75,7 @@
* @author Unascribed
* @version $Revision$ $Date$
*/
-public class HttpRecoverableException extends TransportException {
+public class HttpRecoverableException extends IOException {
/**
* Creates a new HttpRecoverableException with a <tt>null</tt> detail message.
1.20 +26 -10 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java
Index: MultiThreadedHttpConnectionManager.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- MultiThreadedHttpConnectionManager.java 15 Jul 2003 02:19:58 -0000 1.19
+++ MultiThreadedHttpConnectionManager.java 16 Jul 2003 20:48:27 -0000 1.20
@@ -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;
1.13 +15 -5 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java
Index: SimpleHttpConnectionManager.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SimpleHttpConnectionManager.java 12 May 2003 02:42:42 -0000 1.12
+++ SimpleHttpConnectionManager.java 16 Jul 2003 20:48:27 -0000 1.13
@@ -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)
1.9 +6 -11 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URIException.java
Index: URIException.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URIException.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- URIException.java 31 Jan 2003 00:33:36 -0000 1.8
+++ URIException.java 16 Jul 2003 20:48:27 -0000 1.9
@@ -63,19 +63,14 @@
package org.apache.commons.httpclient;
-import java.io.IOException;
-
/**
* The URI parsing and escape encoding exception.
- * <p>
- * Why is it from IOException?
- * To simplify the programming style for the inherited exception instances.
- * <p>
*
* @author <a href="mailto:jericho at apache.org">Sung-Gu</a>
+ * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
* @version $Revision$ $Date: 2002/03/14 15:14:01
*/
-public class URIException extends IOException {
+public class URIException extends HttpException {
// ----------------------------------------------------------- constructors
1.22 +6 -5 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java
Index: HeadMethod.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- HeadMethod.java 15 Jul 2003 12:30:16 -0000 1.21
+++ HeadMethod.java 16 Jul 2003 20:48:28 -0000 1.22
@@ -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)");
1.11 +5 -5 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestGetMethodLocal.java
Index: TestGetMethodLocal.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestGetMethodLocal.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestGetMethodLocal.java 5 Mar 2003 04:02:56 -0000 1.10
+++ TestGetMethodLocal.java 16 Jul 2003 20:48:28 -0000 1.11
@@ -210,7 +210,7 @@
client.executeMethod(method2);
assertEquals(0, method2.getRecoverableExceptionCount() );
}
- catch (IOException ioe) {
+ catch (Exception ioe) {
fail("Problem executing method : " + ioe.toString() );
}
1.9 +28 -24 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java
Index: TestHttpConnectionManager.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TestHttpConnectionManager.java 28 Apr 2003 23:19:58 -0000 1.8
+++ TestHttpConnectionManager.java 16 Jul 2003 20:48:28 -0000 1.9
@@ -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) {
}
}
1.4 +3 -3 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodCharEncoding.java
Index: TestMethodCharEncoding.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodCharEncoding.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestMethodCharEncoding.java 15 Jul 2003 12:46:33 -0000 1.3
+++ TestMethodCharEncoding.java 16 Jul 2003 20:48:28 -0000 1.4
@@ -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("/");
1.11 +4 -5 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodsExternalHost.java
Index: TestMethodsExternalHost.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestMethodsExternalHost.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestMethodsExternalHost.java 5 Jul 2003 22:31:21 -0000 1.10
+++ TestMethodsExternalHost.java 16 Jul 2003 20:48:28 -0000 1.11
@@ -219,7 +219,6 @@
} catch (IOException e) {
return; // IOException and HttpException are ok
}
-
fail("Should have thrown an exception");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org