hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1348580 - in /httpcomponents/httpclient/branches/decorator-refactoring: ./ httpclient/src/main/java/org/apache/http/client/methods/ httpclient/src/main/java/org/apache/http/impl/client/ httpclient/src/main/java/org/apache/http/impl/client/...
Date Sun, 10 Jun 2012 12:32:24 GMT
Author: olegk
Date: Sun Jun 10 12:32:23 2012
New Revision: 1348580

URL: http://svn.apache.org/viewvc?rev=1348580&view=rev
Log:
Deprecated AbortableHttpRequest in favor of HttpExecutionAware; some test cases are currently
broken

Added:
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
      - copied, changed from r1348409, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/RequestAbortedException.java
      - copied, changed from r1348409, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java
Modified:
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BackoffStrategyFacade.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BasicHttpClient.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/MainRequestExecutor.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/ProtocolFacade.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RedirectFacade.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RetryFacade.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java
    httpcomponents/httpclient/branches/decorator-refactoring/pom.xml

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
Sun Jun 10 12:32:23 2012
@@ -39,10 +39,11 @@ import org.apache.http.conn.ManagedClien
  * Interface representing an HTTP request that can be aborted by shutting
  * down the underlying HTTP connection.
  *
- *
- * <!-- empty lines to avoid svn diff problems -->
  * @since 4.0
+ * 
+ * @deprecated (4.3) use {@link HttpExecutionAware}
  */
+@Deprecated
 public interface AbortableHttpRequest {
 
     /**

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
(from r1348409, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java&r1=1348409&r2=1348580&rev=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
Sun Jun 10 12:32:23 2012
@@ -27,56 +27,32 @@
 
 package org.apache.http.client.methods;
 
-import java.io.IOException;
-
-import org.apache.http.client.HttpClient;
-import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.ClientConnectionRequest;
 import org.apache.http.conn.ConnectionReleaseTrigger;
 import org.apache.http.conn.ManagedClientConnection;
 
 /**
- * Interface representing an HTTP request that can be aborted by shutting
- * down the underlying HTTP connection.
- *
+ * Interface to be implemented by any object that wishes to be notified of request execution

+ * events.
  *
- * <!-- empty lines to avoid svn diff problems -->
- * @since 4.0
+ * @since 4.3
  */
-public interface AbortableHttpRequest {
+public interface HttpExecutionAware {
 
+    boolean isAborted();
+    
     /**
      * Sets the {@link ClientConnectionRequest} callback that can be
      * used to abort a long-lived request for a connection.
-     * If the request is already aborted, throws an {@link IOException}.
-     *
-     * @see ClientConnectionManager
      */
-    void setConnectionRequest(ClientConnectionRequest connRequest) throws IOException;
+    void setConnectionRequest(ClientConnectionRequest connRequest);
 
     /**
      * Sets the {@link ConnectionReleaseTrigger} callback that can
      * be used to abort an active connection.
      * Typically, this will be the {@link ManagedClientConnection} itself.
-     * If the request is already aborted, throws an {@link IOException}.
-     */
-    void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
-
-    /**
-     * Aborts this http request. Any active execution of this method should
-     * return immediately. If the request has not started, it will abort after
-     * the next execution. Aborting this request will cause all subsequent
-     * executions with this request to fail.
-     *
-     * @see HttpClient#execute(HttpUriRequest)
-     * @see HttpClient#execute(org.apache.http.HttpHost,
-     *      org.apache.http.HttpRequest)
-     * @see HttpClient#execute(HttpUriRequest,
-     *      org.apache.http.protocol.HttpContext)
-     * @see HttpClient#execute(org.apache.http.HttpHost,
-     *      org.apache.http.HttpRequest, org.apache.http.protocol.HttpContext)
      */
-    void abort();
+    void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger);
 
 }
 

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java
Sun Jun 10 12:32:23 2012
@@ -51,9 +51,10 @@ import org.apache.http.params.HttpProtoc
  *
  * @since 4.0
  */
+@SuppressWarnings("deprecation")
 @NotThreadSafe
 public abstract class HttpRequestBase extends AbstractHttpMessage
-    implements HttpUriRequest, AbortableHttpRequest, Cloneable {
+    implements HttpUriRequest, HttpExecutionAware, AbortableHttpRequest, Cloneable {
 
     private Lock abortLock;
     private volatile boolean aborted;
@@ -101,10 +102,9 @@ public abstract class HttpRequestBase ex
         this.uri = uri;
     }
 
-    public void setConnectionRequest(final ClientConnectionRequest connRequest)
-            throws IOException {
+    public void setConnectionRequest(final ClientConnectionRequest connRequest) {
         if (this.aborted) {
-            throw new IOException("Request already aborted");
+            return;
         }
         this.abortLock.lock();
         try {
@@ -114,10 +114,9 @@ public abstract class HttpRequestBase ex
         }
     }
 
-    public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger)
-            throws IOException {
+    public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
         if (this.aborted) {
-            throw new IOException("Request already aborted");
+            return;
         }
         this.abortLock.lock();
         try {

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/RequestAbortedException.java
(from r1348409, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/RequestAbortedException.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/RequestAbortedException.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java&r1=1348409&r2=1348580&rev=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/RequestAbortedException.java
Sun Jun 10 12:32:23 2012
@@ -25,23 +25,31 @@
  *
  */
 
-package org.apache.http.impl.client.exec;
+package org.apache.http.impl.client;
 
-import java.io.IOException;
+import java.io.InterruptedIOException;
 
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpContext;
+import org.apache.http.annotation.Immutable;
 
 /**
+ * Signals that the request has been aborted.
+ *
  * @since 4.3
  */
-public interface HttpClientRequestExecutor {
+@Immutable
+public class RequestAbortedException extends InterruptedIOException {
+
+    private static final long serialVersionUID = 4973849966012490112L;
 
-    HttpResponse execute(
-            HttpRoute route, 
-            HttpRequestWrapper request, 
-            HttpContext context) throws IOException, HttpException;
+    public RequestAbortedException(final String message) {
+        super(message);
+    }
+
+    public RequestAbortedException(final String message, final Throwable cause) {
+        super(message);
+        if (cause != null) {
+            initCause(cause);
+        }
+    }
 
 }

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BackoffStrategyFacade.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BackoffStrategyFacade.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BackoffStrategyFacade.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BackoffStrategyFacade.java
Sun Jun 10 12:32:23 2012
@@ -35,6 +35,7 @@ import org.apache.http.HttpResponse;
 import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.client.BackoffManager;
 import org.apache.http.client.ConnectionBackoffStrategy;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.protocol.HttpContext;
 
@@ -70,13 +71,20 @@ public class BackoffStrategyFacade imple
     public HttpResponse execute(
             final HttpRoute route,
             final HttpRequestWrapper request,
-            final HttpContext context) throws IOException, HttpException {
+            final HttpContext context,
+            final HttpExecutionAware execAware) throws IOException, HttpException {
+        if (route == null) {
+            throw new IllegalArgumentException("HTTP route may not be null");
+        }
         if (request == null) {
-            throw new IllegalArgumentException("Request may not be null");
+            throw new IllegalArgumentException("HTTP request may not be null");
+        }
+        if (context == null) {
+            throw new IllegalArgumentException("HTTP context may not be null");
         }
         HttpResponse out;
         try {
-            out = this.requestExecutor.execute(route, request, context);
+            out = this.requestExecutor.execute(route, request, context, execAware);
         } catch (RuntimeException ex) {
             if (this.connectionBackoffStrategy.shouldBackoff(ex)) {
                 this.backoffManager.backOff(route);

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BasicHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BasicHttpClient.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BasicHttpClient.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/BasicHttpClient.java
Sun Jun 10 12:32:23 2012
@@ -43,6 +43,7 @@ import org.apache.http.auth.AuthState;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.protocol.ClientContext;
@@ -50,6 +51,7 @@ import org.apache.http.client.utils.URIU
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.routing.HttpRoutePlanner;
 import org.apache.http.impl.client.ClientParamsStack;
+import org.apache.http.impl.client.RequestAbortedException;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
@@ -150,9 +152,15 @@ public abstract class BasicHttpClient im
             HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
             wrapper.setParams(params);
             wrapper.setVirtualHost(virtualHost);
-
+            HttpExecutionAware execListner = null;
+            if (request instanceof HttpExecutionAware) {
+                execListner = (HttpExecutionAware) request;
+                if (execListner.isAborted()) {
+                    throw new RequestAbortedException("Request aborted");
+                }
+            }
             HttpRoute route = determineRoute(target, request, context);
-            return this.requestExecutor.execute(route, wrapper, execContext);
+            return this.requestExecutor.execute(route, wrapper, execContext, execListner);
         } catch (HttpException httpException) {
             throw new ClientProtocolException(httpException);
         }

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/HttpClientRequestExecutor.java
Sun Jun 10 12:32:23 2012
@@ -31,6 +31,7 @@ import java.io.IOException;
 
 import org.apache.http.HttpException;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.protocol.HttpContext;
 
@@ -42,6 +43,7 @@ public interface HttpClientRequestExecut
     HttpResponse execute(
             HttpRoute route, 
             HttpRequestWrapper request, 
-            HttpContext context) throws IOException, HttpException;
+            HttpContext context,
+            HttpExecutionAware execAware) throws IOException, HttpException;
 
 }

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/MainRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/MainRequestExecutor.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/MainRequestExecutor.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/MainRequestExecutor.java
Sun Jun 10 12:32:23 2012
@@ -48,7 +48,7 @@ import org.apache.http.auth.UsernamePass
 import org.apache.http.client.AuthenticationStrategy;
 import org.apache.http.client.NonRepeatableRequestException;
 import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.methods.AbortableHttpRequest;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.client.params.HttpClientParams;
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.BasicManagedEntity;
@@ -63,6 +63,7 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.entity.BufferedHttpEntity;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.impl.client.HttpAuthenticator;
+import org.apache.http.impl.client.RequestAbortedException;
 import org.apache.http.impl.client.TunnelRefusedException;
 import org.apache.http.impl.conn.ConnectionShutdownException;
 import org.apache.http.message.BasicHttpRequest;
@@ -166,7 +167,17 @@ public class MainRequestExecutor impleme
     public HttpResponse execute(
             final HttpRoute route,
             final HttpRequestWrapper request,
-            final HttpContext context) throws HttpException, IOException {
+            final HttpContext context,
+            final HttpExecutionAware execAware) throws IOException, HttpException {
+        if (route == null) {
+            throw new IllegalArgumentException("HTTP route may not be null");
+        }
+        if (request == null) {
+            throw new IllegalArgumentException("HTTP request may not be null");
+        }
+        if (context == null) {
+            throw new IllegalArgumentException("HTTP context may not be null");
+        }
 
         AuthState targetAuthState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
         if (targetAuthState == null) {
@@ -177,7 +188,6 @@ public class MainRequestExecutor impleme
             proxyAuthState = new AuthState();
         }
 
-        HttpRequest original = request.getOriginal();
         Header[] origheaders = request.getAllHeaders();
 
         Object userToken = context.getAttribute(ClientContext.USER_TOKEN);
@@ -198,17 +208,20 @@ public class MainRequestExecutor impleme
                 if (managedConn == null) {
                     ClientConnectionRequest connRequest = connManager.requestConnection(
                             route, userToken);
-                    if (original instanceof AbortableHttpRequest) {
-                        ((AbortableHttpRequest) request).setConnectionRequest(connRequest);
+                    if (execAware != null) {
+                        if (execAware.isAborted()) {
+                            connRequest.abortRequest();
+                            throw new RequestAbortedException("Request aborted");
+                        } else {
+                            execAware.setConnectionRequest(connRequest);
+                        }
                     }
 
                     long timeout = HttpClientParams.getConnectionManagerTimeout(params);
                     try {
                         managedConn = connRequest.getConnection(timeout, TimeUnit.MILLISECONDS);
                     } catch(InterruptedException interrupted) {
-                        InterruptedIOException iox = new InterruptedIOException();
-                        iox.initCause(interrupted);
-                        throw iox;
+                        throw new RequestAbortedException("Request aborted", interrupted);
                     }
 
                     if (HttpConnectionParams.isStaleCheckingEnabled(params)) {
@@ -223,8 +236,13 @@ public class MainRequestExecutor impleme
                     }
                 }
 
-                if (original instanceof AbortableHttpRequest) {
-                    ((AbortableHttpRequest) request).setReleaseTrigger(managedConn);
+                if (execAware != null) {
+                    if (execAware.isAborted()) {
+                        managedConn.releaseConnection();
+                        throw new RequestAbortedException("Request aborted");
+                    } else {
+                        execAware.setReleaseTrigger(managedConn);
+                    }
                 }
 
                 if (!managedConn.isOpen()) {
@@ -246,6 +264,10 @@ public class MainRequestExecutor impleme
                     break;
                 }
 
+                if (execAware != null && execAware.isAborted()) {
+                    throw new RequestAbortedException("Request aborted");
+                }
+                
                 String userinfo = request.getURI().getUserInfo();
                 if (userinfo != null) {
                     targetAuthState.update(

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/ProtocolFacade.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/ProtocolFacade.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/ProtocolFacade.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/ProtocolFacade.java
Sun Jun 10 12:32:23 2012
@@ -38,6 +38,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.ProtocolException;
 import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.protocol.ExecutionContext;
@@ -99,7 +100,17 @@ public class ProtocolFacade implements H
     public HttpResponse execute(
             final HttpRoute route,
             final HttpRequestWrapper request,
-            final HttpContext context) throws HttpException, IOException {
+            final HttpContext context,
+            final HttpExecutionAware execAware) throws IOException, HttpException {
+        if (route == null) {
+            throw new IllegalArgumentException("HTTP route may not be null");
+        }
+        if (request == null) {
+            throw new IllegalArgumentException("HTTP request may not be null");
+        }
+        if (context == null) {
+            throw new IllegalArgumentException("HTTP context may not be null");
+        }
         HttpHost target = route.getTargetHost();
         HttpHost proxy = route.getProxyHost();
 
@@ -125,7 +136,7 @@ public class ProtocolFacade implements H
 
         this.httpProcessor.process(request, context);
         
-        HttpResponse response = this.requestExecutor.execute(route, request, context);
+        HttpResponse response = this.requestExecutor.execute(route, request, context, execAware);
         
         // Run response protocol interceptors
         context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RedirectFacade.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RedirectFacade.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RedirectFacade.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RedirectFacade.java
Sun Jun 10 12:32:23 2012
@@ -42,6 +42,7 @@ import org.apache.http.auth.AuthScheme;
 import org.apache.http.auth.AuthState;
 import org.apache.http.client.RedirectException;
 import org.apache.http.client.RedirectStrategy;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.params.HttpClientParams;
 import org.apache.http.client.protocol.ClientContext;
@@ -92,14 +93,25 @@ public class RedirectFacade implements H
     public HttpResponse execute(
             final HttpRoute route,
             final HttpRequestWrapper request,
-            final HttpContext context) throws IOException, HttpException {
+            final HttpContext context,
+            final HttpExecutionAware execAware) throws IOException, HttpException {
+        if (route == null) {
+            throw new IllegalArgumentException("HTTP route may not be null");
+        }
+        if (request == null) {
+            throw new IllegalArgumentException("HTTP request may not be null");
+        }
+        if (context == null) {
+            throw new IllegalArgumentException("HTTP context may not be null");
+        }
         HttpParams params = request.getParams();
         int redirectCount = 0;
         int maxRedirects = params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
         HttpRoute currentRoute = route;
         HttpRequestWrapper currentRequest = request;
         for (;;) {
-            HttpResponse response = requestExecutor.execute(currentRoute, currentRequest,
context);
+            HttpResponse response = requestExecutor.execute(
+                    currentRoute, currentRequest, context, execAware);
             if (HttpClientParams.isRedirecting(params) &&
                     this.redirectStrategy.isRedirected(currentRequest, response, context))
{
 

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RetryFacade.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RetryFacade.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RetryFacade.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/exec/RetryFacade.java
Sun Jun 10 12:32:23 2012
@@ -37,6 +37,7 @@ import org.apache.http.HttpResponse;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.client.NonRepeatableRequestException;
+import org.apache.http.client.methods.HttpExecutionAware;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.protocol.HttpContext;
@@ -66,12 +67,22 @@ public class RetryFacade implements Http
     }
 
     public HttpResponse execute(
-            final HttpRoute route, 
-            final HttpRequestWrapper request, 
-            final HttpContext context) throws IOException, HttpException {
+            final HttpRoute route,
+            final HttpRequestWrapper request,
+            final HttpContext context,
+            final HttpExecutionAware execAware) throws IOException, HttpException {
+        if (route == null) {
+            throw new IllegalArgumentException("HTTP route may not be null");
+        }
+        if (request == null) {
+            throw new IllegalArgumentException("HTTP request may not be null");
+        }
+        if (context == null) {
+            throw new IllegalArgumentException("HTTP context may not be null");
+        }
         for (int execCount = 0;; execCount++) {
             try {
-                this.requestExecutor.execute(route, request, context);
+                this.requestExecutor.execute(route, request, context, execAware);
             } catch (IOException ex) {
                 HttpRequest original = request.getOriginal();
                 if (original instanceof HttpUriRequest && ((HttpUriRequest) original).isAborted())
{

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java
Sun Jun 10 12:32:23 2012
@@ -38,7 +38,6 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.ProtocolVersion;
-import org.apache.http.client.methods.AbortableHttpRequest;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.ClientConnectionRequest;
@@ -52,7 +51,6 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.client.DefaultRequestDirector;
-import org.apache.http.impl.client.RequestWrapper;
 import org.apache.http.localserver.BasicServerTestBase;
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.message.BasicHeader;
@@ -125,7 +123,6 @@ public class TestAbortHandling extends B
 
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
         Assert.assertNotNull("Request should exist",reqWrapper);
-        Assert.assertEquals(1,((RequestWrapper) reqWrapper).getExecCount());
     }
 
     /**
@@ -494,7 +491,7 @@ public class TestAbortHandling extends B
         }
 
         @Override
-        public void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException
{
+        public void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) {
             try {
                 if(!releaseTriggerLatch.await(1, TimeUnit.SECONDS))
                     throw new RuntimeException("Waited too long...");

Modified: httpcomponents/httpclient/branches/decorator-refactoring/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/pom.xml?rev=1348580&r1=1348579&r2=1348580&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/pom.xml (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/pom.xml Sun Jun 10 12:32:23 2012
@@ -76,7 +76,7 @@
     <junit.version>4.9</junit.version>
     <easymock.version>2.5.2</easymock.version>
     <mockito.version>1.8.5</mockito.version>
-    <api.comparison.version>4.1</api.comparison.version>
+    <api.comparison.version>4.2</api.comparison.version>
   </properties>
 
   <repositories>



Mime
View raw message