commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: [httpclient] java.io.InterruptedIOException not thrown
Date Wed, 13 Aug 2003 14:03:40 GMT
Hi Mike,

Sorry for the slow response.  Yes, this is the correct behavior for 
getResponseBody() and getResponseBodyAsString().  These methods do not 
throw checked exceptions and therefore have to eat the various 
IOExceptions that can occur.  This was not well documented in the 
Javadocs until recently 
<http://cvs.apache.org/viewcvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java?rev=1.23.2.3&content-type=text/vnd.viewcvs-markup>.

If you would like to see these exceptions please use 
HttpMethod.getResponseBodyAsStream() and buffer the bytes manually.

Mike



----------------------------------
Hi there,

I recently upgraded to RC1 and currently have a problem with our network
connection.

A java.io.InterruptedIOException is logged when I do a
getResponseBodyAsString(),
but never thrown, I get a "" or null body. Is this the way it should be ?

regards   Mike

--- log ---

DEBUG 14:22:01 HttpAction: execute() - bla bla
[ERROR] HttpMethodBase - -I/O failure reading response body
<java.io.InterruptedIOException: Read timed
out>java.io.InterruptedIOException:
Read timed out
         at java.net.SocketInputStream.socketRead(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:85)
         at
com.sun.net.ssl.internal.ssl.InputRecord.read([DashoPro-V1.2-120198])
         at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
         at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
         at
com.sun.net.ssl.internal.ssl.AppInputStream.read([DashoPro-V1.2-120198])
         at java.io.FilterInputStream.read(FilterInputStream.java:109)
         at java.io.PushbackInputStream.read(PushbackInputStream.java:159)
         at
org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.jav
a:198)
         at java.io.FilterInputStream.read(FilterInputStream.java:109)
         at
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream
.java:142)
         at java.io.FilterInputStream.read(FilterInputStream.java:88)
         at
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream
.java:161)
         at
org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.
java:685)
         at
org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMet
hodBase.java:734)
         at watchdog2.plugins.HttpAction.execute(HttpAction.java:140)
         at java.lang.reflect.Method.invoke(Native Method)
         at watchdog2.utils.Utils.execute(Utils.java:165)
         at watchdog2.utils.SaveExecute.run(SaveExecute.java:38)

--- code ---

     // retrieve web page
     try {
         if (client.executeMethod(m) != HttpStatus.SC_OK) {
             throw new WatchdogException(node.getPath() + " - HTTP 
error: " +
m.getStatusLine());
         }
         log.debug("execute() - bla bla");

         // THIS IS WHERE THE EXCEPTION IS LOGGED (HttpAction.java:140)
         if (body) response = response + m.getResponseBodyAsString();

     } catch (UnknownHostException uhe) {
         log.debug("execute() - unknown host: " + url);
         throw new WatchdogFatalException(node.getPath() + " - Unknown host:
" + uhe);
     } catch (IOException ioe) {
         log.debug("execute() - exception: " + ioe, ioe);
         throw new WatchdogException(node.getPath() + " - exception: " +
ioe);
     } catch (Exception e) {
         log.debug("execute() - exception: " + e, e);
         e.printStackTrace();
         throw new WatchdogException(node.getPath() + " - exception: " + e);
     } finally {
         m.releaseConnection();
     }




Mime
View raw message