On Friday, June 20, 2003, at 11:54 AM, Adrian Sutton wrote:



On Friday, June 20, 2003, at 11:41 AM, Michael Becke wrote:


Adrian,

I'm looking into to this and I agree it is quite strange. The part I don't understand is why the second attempt to write to the socket fails. The socket is not being closed on the HttpClient side until after the failure occurs. Any thoughts on how the connection is being closed?

Well I'm not really sure. It appears that the HttpConnection class thinks that it's still open but the underlying stream is actually closed. I'm just writing some tests to check this at the moment, but I believe it has to be the case because in HttpMethodBase.writeRequest at line 2179 we call conn.flushRequestStream which is what's causing the exception. However, immediately before that call if you add a debug statement to check if the connection is open, conn.isOpen() returns true.

I appear to be right in this theory, the underlying connection is closed an HttpConnection doesn't know about it. The following patch (which I hope isn't the best solution we can come up with) seems to solve the problem (though I have more testing to do on it).


Index: HttpConnection.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/ httpclient/HttpConnection.java,v
retrieving revision 1.67
diff -u -u -r1.67 HttpConnection.java
--- HttpConnection.java 26 May 2003 22:07:21 -0000 1.67
+++ HttpConnection.java 20 Jun 2003 01:59:23 -0000
@@ -480,6 +480,14 @@
LOG.debug("Connection is stale, closing...");
close();
}
+ if (inputStream != null) {
+ try {
+ isOpen = inputStream.available() >= 0;
+ } catch(IOException e) {
+ isOpen = false;
+ LOG.debug("Underlying connectin is closed.", e);
+ }
+ }
return isOpen;
}



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to