hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r826037 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl: client/DefaultRequestDirector.java conn/AbstractClientConnAdapter.java conn/AbstractPooledConnAdapter.java conn/ConnectionShutdownException.java
Date Fri, 16 Oct 2009 19:00:18 GMT
Author: olegk
Date: Fri Oct 16 19:00:17 2009
New Revision: 826037

URL: http://svn.apache.org/viewvc?rev=826037&view=rev
Log:
HTTPCLIENT-881: An I/O operation on an aborted or released connection will result in an InterruptedIOException

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
  (with props)
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java?rev=826037&r1=826036&r2=826037&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
Fri Oct 16 19:00:17 2009
@@ -80,6 +80,7 @@
 import org.apache.http.conn.routing.HttpRoutePlanner;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.entity.BufferedHttpEntity;
+import org.apache.http.impl.conn.ConnectionShutdownException;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
@@ -559,6 +560,8 @@
 
             return response;
             
+        } catch (ConnectionShutdownException ex) {
+            throw new InterruptedIOException("Connection has been shut down");
         } catch (HttpException ex) {
             abortConnection();
             throw ex;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java?rev=826037&r1=826036&r2=826037&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
Fri Oct 16 19:00:17 2009
@@ -129,7 +129,7 @@
      */
     protected final void assertNotAborted() throws InterruptedIOException {
         if (shutdown) {
-            throw new InterruptedIOException("Connection has been shut down.");
+            throw new InterruptedIOException("Connection has been shut down");
         }
     }
 
@@ -142,7 +142,7 @@
     protected final void assertValid(
             final OperatedClientConnection wrappedConn) {
         if (wrappedConn == null) {
-            throw new IllegalStateException("No wrapped connection.");
+            throw new ConnectionShutdownException();
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java?rev=826037&r1=826036&r2=826037&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
Fri Oct 16 19:00:17 2009
@@ -72,7 +72,7 @@
      */
     protected final void assertAttached() {
         if (poolEntry == null) {
-            throw new IllegalStateException("Adapter is detached.");
+            throw new ConnectionShutdownException();
         }
     }
 
@@ -87,7 +87,6 @@
     }
 
     public HttpRoute getRoute() {
-
         assertAttached();
         return (poolEntry.tracker == null) ?
             null : poolEntry.tracker.toRoute();
@@ -96,35 +95,36 @@
     public void open(HttpRoute route,
                      HttpContext context, HttpParams params)
         throws IOException {
-
+        assertNotAborted();
         assertAttached();
         poolEntry.open(route, context, params);
     }
 
     public void tunnelTarget(boolean secure, HttpParams params)
         throws IOException {
-
+        assertNotAborted();
         assertAttached();
         poolEntry.tunnelTarget(secure, params);
     }
 
     public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
         throws IOException {
-
+        assertNotAborted();
         assertAttached();
         poolEntry.tunnelProxy(next, secure, params);
     }
 
     public void layerProtocol(HttpContext context, HttpParams params)
         throws IOException {
-
+        assertNotAborted();
         assertAttached();
         poolEntry.layerProtocol(context, params);
     }
 
     public void close() throws IOException {
-        if (poolEntry != null)
-            poolEntry.shutdownEntry();
+        AbstractPoolEntry entry = poolEntry;
+        if (entry != null)
+            entry.shutdownEntry();
 
         OperatedClientConnection conn = getWrappedConnection();
         if (conn != null) {
@@ -133,8 +133,9 @@
     }
 
     public void shutdown() throws IOException {
-        if (poolEntry != null)
-            poolEntry.shutdownEntry();
+        AbstractPoolEntry entry = poolEntry;
+        if (entry != null)
+            entry.shutdownEntry();
 
         OperatedClientConnection conn = getWrappedConnection();
         if (conn != null) {

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java?rev=826037&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
(added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
Fri Oct 16 19:00:17 2009
@@ -0,0 +1,50 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.conn;
+
+import org.apache.http.annotation.Immutable;
+
+/**
+ * Signals that the connection has been shut down or released back to the 
+ * the connection pool
+ * 
+ * @since 4.1
+ */
+@Immutable
+public class ConnectionShutdownException extends IllegalStateException {
+
+    private static final long serialVersionUID = 5868657401162844497L;
+
+    /**
+     * Creates a new ConnectionShutdownException with a <tt>null</tt> detail
message.
+     */
+    public ConnectionShutdownException() {
+        super();
+    }
+     
+}

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message