You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2005/08/08 22:29:36 UTC

svn commit: r230876 - in /jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient: HttpConnection.java HttpMethodBase.java

Author: olegk
Date: Mon Aug  8 13:29:32 2005
New Revision: 230876

URL: http://svn.apache.org/viewcvs?rev=230876&view=rev
Log:
PR #35944 (Connection is not released back to the pool if a runtime exception is thrown in HttpMethod#releaseConnection method)

Contributed by Oleg Kalnichevski
Reviewed by Ortwin Glück & Michael Becke

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpConnection.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpConnection.java?rev=230876&r1=230875&r2=230876&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpConnection.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpConnection.java Mon Aug  8 13:29:32 2005
@@ -869,8 +869,11 @@
     public boolean isResponseAvailable() 
         throws IOException {
         LOG.trace("enter HttpConnection.isResponseAvailable()");
-        assertOpen();
-        return this.inputStream.available() > 0;
+        if (this.isOpen) {
+            return this.inputStream.available() > 0;
+        } else {
+            return false;
+        }
     }
 
     /**

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java?rev=230876&r1=230875&r2=230876&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java Mon Aug  8 13:29:32 2005
@@ -1071,19 +1071,15 @@
      * @since 2.0
      */
     public void releaseConnection() {
-
-        if (responseStream != null) {
-            try {
-                // FYI - this may indirectly invoke responseBodyConsumed.
-                responseStream.close();
-            } catch (IOException e) {
-                // the connection may not have been released, let's make sure
-                ensureConnectionRelease();
+        try {
+            if (this.responseStream != null) {
+                try {
+                    // FYI - this may indirectly invoke responseBodyConsumed.
+                    this.responseStream.close();
+                } catch (IOException ignore) {
+                }
             }
-        } else {
-            // Make sure the connection has been released. If the response 
-            // stream has not been set, this is the only way to release the 
-            // connection. 
+        } finally {
             ensureConnectionRelease();
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org