hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r552264 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn: EofSensorInputStream.java EofSensorWatcher.java
Date Sun, 01 Jul 2007 09:37:50 GMT
Author: olegk
Date: Sun Jul  1 02:37:47 2007
New Revision: 552264

URL: http://svn.apache.org/viewvc?view=rev&rev=552264
Log:
Make sure connection gets aborted in case of an IOException (potentially triggering connection
release back to the connection manager)

Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorInputStream.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorWatcher.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorInputStream.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorInputStream.java?view=diff&rev=552264&r1=552263&r2=552264
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorInputStream.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorInputStream.java
Sun Jul  1 02:37:47 2007
@@ -114,7 +114,7 @@
 
 
     /**
-     * Checks whether the underyling stream can be read from.
+     * Checks whether the underlying stream can be read from.
      *
      * @return  <code>true</code> if the underlying stream is accessible,
      *          <code>false</code> if this stream is in EOF mode and
@@ -135,8 +135,13 @@
         int l = -1;
 
         if (isReadAllowed()) {
-            l = wrappedStream.read();
-            checkEOF(l);
+            try {
+                l = wrappedStream.read();
+                checkEOF(l);
+            } catch (IOException ex) {
+                checkAbort();
+                throw ex;
+            }
         }
 
         return l;
@@ -148,8 +153,13 @@
         int l = -1;
 
         if (isReadAllowed()) {
-            l = wrappedStream.read(b,  off,  len);
-            checkEOF(l);
+            try {
+                l = wrappedStream.read(b,  off,  len);
+                checkEOF(l);
+            } catch (IOException ex) {
+                checkAbort();
+                throw ex;
+            }
         }
 
         return l;
@@ -161,8 +171,13 @@
         int l = -1;
 
         if (isReadAllowed()) {
-            l = wrappedStream.read(b);
-            checkEOF(l);
+            try {
+                l = wrappedStream.read(b);
+                checkEOF(l);
+            } catch (IOException ex) {
+                checkAbort();
+                throw ex;
+            }
         }
         return l;
     }
@@ -173,8 +188,13 @@
         int a = 0; // not -1
 
         if (isReadAllowed()) {
-            a = wrappedStream.available();
-            // no checkEOF() here, available() can't trigger EOF
+            try {
+                a = wrappedStream.available();
+                // no checkEOF() here, available() can't trigger EOF
+            } catch (IOException ex) {
+                checkAbort();
+                throw ex;
+            }
         }
 
         return a;

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorWatcher.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorWatcher.java?view=diff&rev=552264&r1=552263&r2=552264
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorWatcher.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorWatcher.java
Sun Jul  1 02:37:47 2007
@@ -90,6 +90,9 @@
      * Indicates that the {@link EofSensorInputStream stream} is aborted.
      * This method will be called only if EOF was <i>not</i> detected
      * before aborting. Otherwise, {@link #eofDetected eofDetected} is called.
+     * <p/>
+     * This method will also be invoked when an input operation causes an
+     * IOException to be thrown to make sure the input stream gets shut down. 
      *
      * @param wrapped   the underlying stream which has not reached EOF
      *



Mime
View raw message