protected boolean isStale() throws IOException {
        boolean isStale = true;
        if (isOpen) {
            // the connection is open, but now we have to see if we can read it
            // assume the connection is not stale.
            isStale = false;
            try {
                if (inputStream.available() <= 0) {
                    try {
                        socket.setSoTimeout(1);
                        inputStream.mark(1);
                        int byteRead = inputStream.read();
                        if (byteRead == -1) {
                            // again - if the socket is reporting all data read,
                            // probably stale
                            isStale = true;
                        } else {
                            inputStream.reset();
                        }
                    } finally {
                        socket.setSoTimeout(this.params.getSoTimeout());
                    }
                }
            } catch (InterruptedIOException e) {
                if (!ExceptionUtil.isSocketTimeoutException(e)) {
                    throw e;
                }
                // aha - the connection is NOT stale - continue on!
            } catch (IOException e) {
                // oops - the connection is stale, the read or soTimeout failed.
                LOG.debug(
                    "An error occurred while reading from the socket, is appears to be stale",
                    e
                );
                isStale = true;
            }
        }

        return isStale;
    }
protected boolean isStale ( ) throws IOException { boolean isStale = true ; if ( isOpen ) { isStale = false ; try { if ( inputStream . available ( ) <= 0 ) { try { socket . setSoTimeout ( 1 ) ; inputStream . mark ( 1 ) ; int byteRead = inputStream . read ( ) ; if ( byteRead == - 1 ) { isStale = true ; } else { inputStream . reset ( ) ; } } finally { socket . setSoTimeout ( this . params . getSoTimeout ( ) ) ; } } } catch ( InterruptedIOException e ) { if ( ! ExceptionUtil . isSocketTimeoutException ( e ) ) { throw e ; } } catch ( IOException e ) { LOG . debug ( "An error occurred while reading from the socket, is appears to be stale" , e ) ; isStale = true ; } } return isStale ; }
Determines whether this connection is "stale", which is to say that either
it is no longer open, or an attempt to read the connection would fail.

<p>Unfortunately, due to the limitations of the JREs prior to 1.4, it is
not possible to test a connection to see if both the read and write channels
are open - except by reading and writing.  This leads to a difficulty when
some connections leave the "write" channel open, but close the read channel
and ignore the request.  This function attempts to ameliorate that
problem by doing a test read, assuming that the caller will be doing a
write followed by a read, rather than the other way around.
</p>

<p>To avoid side-effects, the underlying connection is wrapped by a
{@link BufferedInputStream}, so although data might be read, what is visible
to clients of the connection will not change with this call.</p>.

@throws IOException if the stale connection test is interrupted.

@return <tt>true</tt> if the connection is already closed, or a read would
fail.