hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 19063] - recoverable exceptions when reading are not retried
Date Thu, 17 Apr 2003 13:02:10 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19063>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19063

recoverable exceptions when reading are not retried





------- Additional Comments From eric@tibco.com  2003-04-17 13:02 -------
I like Adrian Suttons recent suggestion for detecting whether the socket read
will fail after the write - Set the timeout on the socket to one ms, and try a
read of a single byte before doing the write.  His psuedo code (although I
changed the catch clause after reading the SO_TIMEOUT docs):

if (socketInputStream.available() == 0) {
    try {
        socket.setSoTimeout(1);
        socketInputStream.read();
        socket.setSoTimeout(oldValue);
    } catch (InterruptedIOException e) {
        // We're good to go!
    } catch (IOException e) {
        // Connection is half closed, request will fail.
       throw new HttpRecoverableException("Argg!");
    }
} else {
     // There really shouldn't be data on the input stream before the request is
sent.
     // We probably should throw an exception in this case because the previous
response
     // wasn't fully read.
}

Adrian suggested using a wrapper around the socket input stream that does mark
and reset, but I'd like to suggest the alternative of a PushbackInputStream
wrapper, so if a byte did get read, it could be pushed back.  Perhaps we could
add a function to the HttpConnection called something like "isConnectionStale()"
which would be called by processRequest() instead of calling "isOpen()".  The
stale check could do the "isOpen" check, and attempt to read one byte as per above.

Would this work?

Unfortunately, I have not been able to reproduce the problem with recoverable
exceptions here, so I cannot test the change.  I should have time to put
together a patch some time today or tomorrow, if nobody else can pick it up, but
I would still need someone else to test it.

Mime
View raw message