Index: src/java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== retrieving revision 1.159.2.20 diff -u -r1.159.2.20 HttpMethodBase.java --- src/java/org/apache/commons/httpclient/HttpMethodBase.java 14 Dec 2003 22:41:37 -0000 1.159.2.20 +++ src/java/org/apache/commons/httpclient/HttpMethodBase.java 17 Dec 2003 03:01:33 -0000 @@ -2685,6 +2685,9 @@ doneWithConnection = true; throw httpre; } + } catch (IOException e) { + doneWithConnection = true; + throw e; } } } Index: src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java =================================================================== retrieving revision 1.8.2.2 diff -u -r1.8.2.2 TestHttpConnectionManager.java --- src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java 19 Nov 2003 13:27:42 -0000 1.8.2.2 +++ src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java 17 Dec 2003 03:01:35 -0000 @@ -246,6 +246,39 @@ assertNull("connectionManager should be null", connectionManager); } + public void testWriteRequestReleaseConnection() { + + MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); + connectionManager.setMaxConnectionsPerHost(1); + + HttpClient client = createHttpClient(connectionManager); + + GetMethod get = new GetMethod("/") { + protected boolean writeRequestBody(HttpState state, HttpConnection conn) + throws IOException, HttpException { + throw new IOException("Oh no!!"); + } + }; + + try { + client.executeMethod(get); + fail("An exception should have occurred."); + } catch (HttpException e) { + e.printStackTrace(); + fail("HttpException should not have occurred: " + e); + } catch (IOException e) { + // expected + } + + try { + connectionManager.getConnection(client.getHostConfiguration(), 1); + } catch (HttpException e) { + e.printStackTrace(); + fail("Connection was not released: " + e); + } + + } + public void testReleaseConnection() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();