hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1416177 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/client/execchain/ test/java/org/apache/http/impl/client/execchain/ test/java/org/apache/http/impl/client/integration/
Date Sun, 02 Dec 2012 14:03:54 GMT
Author: olegk
Date: Sun Dec  2 14:03:52 2012
New Revision: 1416177

URL: http://svn.apache.org/viewvc?rev=1416177&view=rev
Log:
Refactored execution proxy classes; entity enclosing requests are enhanced only when necessary

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java
  (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityExecHandler.java
  (with props)
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ResponseProxyHandler.java
  (contents, props changed)
      - copied, changed from r1414815, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpResponseProxy.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpResponseProxy.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityWrapper.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/execchain/TestRequestEntityWrapper.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ClientExecChain.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ConnectionReleaseTriggerImpl.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpRequestWrapper.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ClientExecChain.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ClientExecChain.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ClientExecChain.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ClientExecChain.java
Sun Dec  2 14:03:52 2012
@@ -42,8 +42,8 @@ import org.apache.http.conn.routing.Http
  * <p/>
  * Important: please note it is required for decorators that implement post execution aspects
  * or response post-processing of any sort to release resources associated with the response
- * by calling {@link HttpResponseProxy#close()} methods in case of an I/O, protocol or runtime

- * exception, or in case the response is not propagated to the caller.
+ * by calling {@link CloseableHttpResponse#close()} methods in case of an I/O, protocol or
+ * runtime exception, or in case the response is not propagated to the caller.
  *
  * @since 4.3
  */

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ConnectionReleaseTriggerImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ConnectionReleaseTriggerImpl.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ConnectionReleaseTriggerImpl.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ConnectionReleaseTriggerImpl.java
Sun Dec  2 14:03:52 2012
@@ -27,6 +27,7 @@
 
 package org.apache.http.impl.client.execchain;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
@@ -43,7 +44,7 @@ import org.apache.http.conn.HttpClientCo
  * @since 4.3
  */
 @ThreadSafe
-class ConnectionReleaseTriggerImpl implements ConnectionReleaseTrigger, Cancellable {
+class ConnectionReleaseTriggerImpl implements ConnectionReleaseTrigger, Cancellable, Closeable
{
 
     private final Log log;
 
@@ -145,4 +146,8 @@ class ConnectionReleaseTriggerImpl imple
         return this.released;
     }
 
+    public void close() throws IOException {
+        abortConnection();
+    }
+
 }

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java?rev=1416177&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java
(added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java
Sun Dec  2 14:03:52 2012
@@ -0,0 +1,67 @@
+package org.apache.http.impl.client.execchain;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.client.methods.CloseableHttpResponse;
+
+/**
+ * Execution proxies for HTTP message objects.
+ *
+ * @since 4.3
+ */
+@NotThreadSafe
+class ExecProxies {
+
+    static void enhanceEntity(final HttpEntityEnclosingRequest request) {
+        HttpEntity entity = request.getEntity();
+        if (entity != null && !entity.isRepeatable() && !isEnhanced(entity))
{
+            HttpEntity proxy = (HttpEntity) Proxy.newProxyInstance(
+                    HttpEntity.class.getClassLoader(),
+                    new Class<?>[] { HttpEntity.class },
+                    new RequestEntityExecHandler(entity));
+            request.setEntity(proxy);
+        }
+    }
+
+    static boolean isEnhanced(final HttpEntity entity) {
+        if (entity != null && Proxy.isProxyClass(entity.getClass())) {
+            InvocationHandler handler = Proxy.getInvocationHandler(entity);
+            return handler instanceof RequestEntityExecHandler;
+        } else {
+            return false;
+        }
+    }
+
+    static boolean isRepeatable(final HttpRequest request) {
+        if (request instanceof HttpEntityEnclosingRequest) {
+            HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
+            if (entity != null) {
+                if (isEnhanced(entity)) {
+                    RequestEntityExecHandler handler = (RequestEntityExecHandler)
+                            Proxy.getInvocationHandler(entity);
+                    if (!handler.isConsumed()) {
+                        return true;
+                    }
+                }
+                return entity.isRepeatable();
+            }
+        }
+        return true;
+    }
+
+    public static CloseableHttpResponse enhanceResponse(
+            final HttpResponse original,
+            final ConnectionReleaseTriggerImpl connReleaseTrigger) {
+        return (CloseableHttpResponse) Proxy.newProxyInstance(
+                ResponseProxyHandler.class.getClassLoader(),
+                new Class<?>[] { CloseableHttpResponse.class },
+                new ResponseProxyHandler(original, connReleaseTrigger));
+    }
+
+}
\ No newline at end of file

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

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpRequestWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpRequestWrapper.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpRequestWrapper.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpRequestWrapper.java
Sun Dec  2 14:03:52 2012
@@ -35,6 +35,7 @@ import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
@@ -53,12 +54,15 @@ import org.apache.http.protocol.HTTP;
 public class HttpRequestWrapper extends AbstractHttpMessage implements HttpRequest {
 
     private final HttpRequest original;
-
+    private final String method;
+    private ProtocolVersion version;
     private URI uri;
 
     private HttpRequestWrapper(final HttpRequest request) {
         super();
         this.original = request;
+        this.version = this.original.getRequestLine().getProtocolVersion();
+        this.method = this.original.getRequestLine().getMethod();
         if (request instanceof HttpUriRequest) {
             this.uri = ((HttpUriRequest) request).getURI();
         } else {
@@ -71,6 +75,10 @@ public class HttpRequestWrapper extends 
         return this.original.getProtocolVersion();
     }
 
+    public void setProtocolVersion(final ProtocolVersion version) {
+        this.version = version;
+    }
+
     public URI getURI() {
         return this.uri;
     }
@@ -80,28 +88,23 @@ public class HttpRequestWrapper extends 
     }
 
     public RequestLine getRequestLine() {
-        ProtocolVersion version = this.original.getRequestLine().getProtocolVersion();
-        String method = this.original.getRequestLine().getMethod();
-        String uritext = null;
+        String requestUri = null;
         if (this.uri != null) {
-            uritext = this.uri.toASCIIString();
+            requestUri = this.uri.toASCIIString();
         } else {
-            uritext = this.original.getRequestLine().getUri();
+            requestUri = this.original.getRequestLine().getUri();
         }
-        if (uritext == null || uritext.length() == 0) {
-            uritext = "/";
+        if (requestUri == null || requestUri.length() == 0) {
+            requestUri = "/";
         }
-        return new BasicRequestLine(method, uritext, version);
+        ProtocolVersion version = this.version != null ? this.version : HttpVersion.HTTP_1_1;
+        return new BasicRequestLine(this.method, requestUri, version);
     }
 
     public HttpRequest getOriginal() {
         return this.original;
     }
 
-    public boolean isRepeatable() {
-        return true;
-    }
-
     @Override
     public String toString() {
         return getRequestLine() + " " + this.headergroup;
@@ -115,7 +118,7 @@ public class HttpRequestWrapper extends 
         public HttpEntityEnclosingRequestWrapper(final HttpEntityEnclosingRequest request)
             throws ProtocolException {
             super(request);
-            setEntity(request.getEntity());
+            this.entity = request.getEntity();
         }
 
         public HttpEntity getEntity() {
@@ -123,7 +126,7 @@ public class HttpRequestWrapper extends 
         }
 
         public void setEntity(final HttpEntity entity) {
-            this.entity = entity != null ? new RequestEntityWrapper(entity) : null;
+            this.entity = entity;
         }
 
         public boolean expectContinue() {
@@ -131,11 +134,6 @@ public class HttpRequestWrapper extends 
             return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
         }
 
-        @Override
-        public boolean isRepeatable() {
-            return this.entity == null || this.entity.isRepeatable();
-        }
-
     }
 
     public static HttpRequestWrapper wrap(final HttpRequest request) throws ProtocolException
{

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
Sun Dec  2 14:03:52 2012
@@ -36,6 +36,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
@@ -164,6 +165,10 @@ public class MainClientExec implements C
             context.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState);
         }
 
+        if (request instanceof HttpEntityEnclosingRequest) {
+            ExecProxies.enhanceEntity((HttpEntityEnclosingRequest) request);
+        }
+
         Object userToken = context.getUserToken();
 
         final ConnectionRequest connRequest = connManager.requestConnection(route, userToken);
@@ -214,7 +219,7 @@ public class MainClientExec implements C
             HttpResponse response = null;
             for (int execCount = 1;; execCount++) {
 
-                if (execCount > 1 && !request.isRepeatable()) {
+                if (execCount > 1 && !ExecProxies.isRepeatable(request)) {
                     throw new NonRepeatableRequestException("Cannot retry request " +
                             "with a non-repeatable request entity.");
                 }
@@ -327,9 +332,9 @@ public class MainClientExec implements C
             if (entity == null || !entity.isStreaming()) {
                 // connection not needed and (assumed to be) in re-usable state
                 releaseTrigger.releaseConnection();
-                return HttpResponseProxy.newProxy(response, null);
+                return ExecProxies.enhanceResponse(response, null);
             } else {
-                return HttpResponseProxy.newProxy(response, releaseTrigger);
+                return ExecProxies.enhanceResponse(response, releaseTrigger);
             }
         } catch (ConnectionShutdownException ex) {
             InterruptedIOException ioex = new InterruptedIOException(

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
Sun Dec  2 14:03:52 2012
@@ -32,6 +32,7 @@ import java.net.URI;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
@@ -116,6 +117,9 @@ public class RedirectExec implements Cli
                     HttpRequest original = currentRequest.getOriginal();
                     currentRequest = HttpRequestWrapper.wrap(redirect);
                     currentRequest.setHeaders(original.getAllHeaders());
+                    if (original instanceof HttpEntityEnclosingRequest) {
+                        ExecProxies.enhanceEntity((HttpEntityEnclosingRequest) request);
+                    }
 
                     URI uri = currentRequest.getURI();
                     HttpHost newTarget = URIUtils.extractHost(uri);

Added: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityExecHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityExecHandler.java?rev=1416177&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityExecHandler.java
(added)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityExecHandler.java
Sun Dec  2 14:03:52 2012
@@ -0,0 +1,62 @@
+package org.apache.http.impl.client.execchain;
+
+import java.io.OutputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.annotation.NotThreadSafe;
+
+/**
+ * A wrapper class for {@link HttpEntity} enclosed in a request message.
+ *
+ * @since 4.3
+ */
+@NotThreadSafe
+class RequestEntityExecHandler implements InvocationHandler  {
+
+    private static final Method WRITE_TO_METHOD;
+
+    static {
+        try {
+            WRITE_TO_METHOD = HttpEntity.class.getMethod("writeTo", OutputStream.class);
+        } catch (NoSuchMethodException ex) {
+            throw new Error(ex);
+        }
+    }
+
+    private final HttpEntity original;
+    private boolean consumed = false;
+
+    RequestEntityExecHandler(final HttpEntity original) {
+        super();
+        this.original = original;
+    }
+
+    public HttpEntity getOriginal() {
+        return original;
+    }
+
+    public boolean isConsumed() {
+        return consumed;
+    }
+
+    public Object invoke(
+            final Object proxy, final Method method, final Object[] args) throws Throwable
{
+        try {
+            if (method.equals(WRITE_TO_METHOD)) {
+                this.consumed = true;
+            }
+            return method.invoke(original, args);
+        } catch (InvocationTargetException ex) {
+            Throwable cause = ex.getCause();
+            if (cause != null) {
+                throw cause;
+            } else {
+                throw ex;
+            }
+        }
+    }
+
+}
\ No newline at end of file

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

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RequestEntityExecHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ResponseProxyHandler.java
(from r1414815, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpResponseProxy.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ResponseProxyHandler.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ResponseProxyHandler.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpResponseProxy.java&r1=1414815&r2=1416177&rev=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/HttpResponseProxy.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ResponseProxyHandler.java
Sun Dec  2 14:03:52 2012
@@ -27,16 +27,15 @@
 
 package org.apache.http.impl.client.execchain;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.methods.CloseableHttpResponse;
 
 /**
  * A proxy class for {@link HttpResponse} that can be used to release client connection
@@ -45,12 +44,22 @@ import org.apache.http.client.methods.Cl
  * @since 4.3
  */
 @NotThreadSafe
-class HttpResponseProxy implements InvocationHandler {
+class ResponseProxyHandler implements InvocationHandler {
+
+    private static final Method CLOSE_METHOD;
+
+    static {
+        try {
+            CLOSE_METHOD = Closeable.class.getMethod("close");
+        } catch (NoSuchMethodException ex) {
+            throw new Error(ex);
+        }
+    }
 
     private final HttpResponse original;
     private final ConnectionReleaseTriggerImpl connReleaseTrigger;
 
-    private HttpResponseProxy(
+    ResponseProxyHandler(
             final HttpResponse original,
             final ConnectionReleaseTriggerImpl connReleaseTrigger) {
         super();
@@ -70,8 +79,7 @@ class HttpResponseProxy implements Invoc
 
     public Object invoke(
             final Object proxy, final Method method, final Object[] args) throws Throwable
{
-        String mname = method.getName();
-        if (mname.equals("close")) {
+        if (method.equals(CLOSE_METHOD)) {
             close();
             return null;
         } else {
@@ -88,13 +96,4 @@ class HttpResponseProxy implements Invoc
         }
     }
 
-    public static CloseableHttpResponse newProxy(
-            final HttpResponse original,
-            final ConnectionReleaseTriggerImpl connReleaseTrigger) {
-        return (CloseableHttpResponse) Proxy.newProxyInstance(
-                HttpResponseProxy.class.getClassLoader(),
-                new Class<?>[] { CloseableHttpResponse.class },
-                new HttpResponseProxy(original, connReleaseTrigger));
-    }
-
 }

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

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ResponseProxyHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
Sun Dec  2 14:03:52 2012
@@ -33,13 +33,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.Header;
 import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.client.NonRepeatableRequestException;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpExecutionAware;
-import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.conn.routing.HttpRoute;
 
@@ -86,8 +84,7 @@ public class RetryExec implements Client
             try {
                 return this.requestExecutor.execute(route, request, context, execAware);
             } catch (IOException ex) {
-                HttpRequest original = request.getOriginal();
-                if (original instanceof HttpUriRequest && ((HttpUriRequest) original).isAborted())
{
+                if (execAware != null && execAware.isAborted()) {
                     this.log.debug("Request has been aborted");
                     throw ex;
                 }
@@ -100,7 +97,7 @@ public class RetryExec implements Client
                     if (this.log.isDebugEnabled()) {
                         this.log.debug(ex.getMessage(), ex);
                     }
-                    if (!request.isRepeatable()) {
+                    if (!ExecProxies.isRepeatable(request)) {
                         this.log.debug("Cannot retry non-repeatable request");
                         throw new NonRepeatableRequestException("Cannot retry request " +
                                 "with a non-repeatable request entity", ex);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java?rev=1416177&r1=1416176&r2=1416177&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
Sun Dec  2 14:03:52 2012
@@ -259,7 +259,7 @@ public class TestClientAuthentication ex
         this.localServer.register("*", new AuthHandler());
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
-                new UsernamePasswordCredentials("test", "test"));
+                new UsernamePasswordCredentials("test", "boom"));
 
         this.httpclient = HttpClients.custom().setCredentialsProvider(credsProvider).build();
 



Mime
View raw message