hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1440519 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/conn/ main/java/org/apache/http/conn/routing/ main/java/org/apache/http/impl/conn/ main/java/org/apache/http/impl/execchain/ test/java/org/apache/http/...
Date Wed, 30 Jan 2013 16:59:07 GMT
Author: olegk
Date: Wed Jan 30 16:59:07 2013
New Revision: 1440519

URL: http://svn.apache.org/viewvc?rev=1440519&view=rev
Log:
Use InetSocketAddress instead of InetAddress in the HttpClientConnectionManager#connect method

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
Wed Jan 30 16:59:07 2013
@@ -27,7 +27,7 @@
 package org.apache.http.conn;
 
 import java.io.IOException;
-import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.http.HttpClientConnection;
@@ -80,7 +80,7 @@ public interface HttpClientConnectionMan
 
     void connect(
             HttpClientConnection conn,
-            HttpHost host, InetAddress localAddress,
+            HttpHost host, InetSocketAddress localAddress,
             int connectTimeout,
             HttpContext context) throws IOException;
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
Wed Jan 30 16:59:07 2013
@@ -28,6 +28,7 @@
 package org.apache.http.conn.routing;
 
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 
 import org.apache.http.HttpHost;
 import org.apache.http.annotation.Immutable;
@@ -255,6 +256,10 @@ public final class HttpRoute implements 
     }
 
 
+    public final InetSocketAddress getLocalSocketAddress() {
+        return this.localAddress != null ? new InetSocketAddress(this.localAddress, 0) :
null;
+    }
+
     public final int getHopCount() {
         return proxyChain.length+1;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
Wed Jan 30 16:59:07 2013
@@ -29,7 +29,6 @@ package org.apache.http.impl.conn;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.Date;
 import java.util.concurrent.TimeUnit;
@@ -304,13 +303,12 @@ public class BasicHttpClientConnectionMa
     public void connect(
             final HttpClientConnection conn,
             final HttpHost host,
-            final InetAddress local,
+            final InetSocketAddress localAddress,
             final int connectTimeout,
             final HttpContext context) throws IOException {
         Args.notNull(conn, "Connection");
         Args.notNull(host, "HTTP host");
         Asserts.check(conn == this.conn, "Connection not obtained from this manager");
-        final InetSocketAddress localAddress = local != null ? new InetSocketAddress(local,
0) : null;
         this.connectionOperator.connect(this.conn, host, localAddress,
                 connectTimeout, this.socketConfig, context);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
Wed Jan 30 16:59:07 2013
@@ -28,7 +28,6 @@ package org.apache.http.impl.conn;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -297,7 +296,7 @@ public class PoolingHttpClientConnection
     public void connect(
             final HttpClientConnection managedConn,
             final HttpHost host,
-            final InetAddress local,
+            final InetSocketAddress localAddress,
             final int connectTimeout,
             final HttpContext context) throws IOException {
         Args.notNull(managedConn, "Connection");
@@ -313,7 +312,6 @@ public class PoolingHttpClientConnection
         if (socketConfig == null) {
             socketConfig = SocketConfig.DEFAULT;
         }
-        final InetSocketAddress localAddress = local != null ? new InetSocketAddress(local,
0) : null;
         this.connectionOperator.connect(
                 conn, host, localAddress, connectTimeout, socketConfig, context);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
Wed Jan 30 16:59:07 2013
@@ -353,7 +353,7 @@ public class MainClientExec implements C
             case HttpRouteDirector.CONNECT_TARGET:
                 this.connManager.connect(
                         managedConn,
-                        route.getTargetHost(), route.getLocalAddress(),
+                        route.getTargetHost(), route.getLocalSocketAddress(),
                         timeout > 0 ? timeout : 0,
                         context);
                 tracker.connectTarget(route.isSecure());
@@ -361,7 +361,7 @@ public class MainClientExec implements C
             case HttpRouteDirector.CONNECT_PROXY:
                 this.connManager.connect(
                         managedConn,
-                        route.getProxyHost(), route.getLocalAddress(),
+                        route.getProxyHost(), route.getLocalSocketAddress(),
                         timeout > 0 ? timeout : 0,
                         context);
                 final HttpHost proxy  = route.getProxyHost();
@@ -434,7 +434,7 @@ public class MainClientExec implements C
             if (!managedConn.isOpen()) {
                 this.connManager.connect(
                         managedConn,
-                        route.getProxyHost(), route.getLocalAddress(),
+                        route.getProxyHost(), route.getLocalSocketAddress(),
                         timeout > 0 ? timeout : 0,
                         context);
             }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
Wed Jan 30 16:59:07 2013
@@ -146,7 +146,7 @@ public class MinimalClientExec implement
                 final int timeout = config.getConnectTimeout();
                 this.connManager.connect(
                     managedConn,
-                    route.getTargetHost(), route.getLocalAddress(),
+                    route.getTargetHost(), route.getLocalSocketAddress(),
                     timeout > 0 ? timeout : 0,
                     context);
             } else {

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
Wed Jan 30 16:59:07 2013
@@ -28,7 +28,7 @@ package org.apache.http.impl.client.inte
 
 import java.io.IOException;
 import java.net.ConnectException;
-import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
@@ -297,7 +297,7 @@ public class TestAbortHandling extends I
         Mockito.doThrow(new ConnectException()).when(connmgr).connect(
                 Mockito.any(HttpClientConnection.class),
                 Mockito.any(HttpHost.class),
-                Mockito.any(InetAddress.class),
+                Mockito.any(InetSocketAddress.class),
                 Mockito.anyInt(),
                 Mockito.any(HttpContext.class));
 
@@ -465,7 +465,7 @@ public class TestAbortHandling extends I
         public void connect(
                 final HttpClientConnection conn,
                 final HttpHost host,
-                final InetAddress localAddress,
+                final InetSocketAddress localAddress,
                 final int connectTimeout,
                 final HttpContext context) throws IOException {
             throw new UnsupportedOperationException("just a mockup");

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java?rev=1440519&r1=1440518&r2=1440519&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
Wed Jan 30 16:59:07 2013
@@ -112,7 +112,7 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
@@ -146,7 +146,7 @@ public class TestConnectionManagement ex
         conn = getConnection(mgr, route);
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         // repeat the communication, no need to prepare the request again
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
@@ -200,7 +200,7 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
@@ -235,7 +235,7 @@ public class TestConnectionManagement ex
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         response = exec.execute(request, conn, context);
@@ -270,7 +270,7 @@ public class TestConnectionManagement ex
         Assert.assertTrue("connection should have been closed", !conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         response = exec.execute(request, conn, context);
@@ -297,7 +297,7 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         final HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         Assert.assertEquals(1, mgr.getTotalStats().getLeased());
         Assert.assertEquals(1, mgr.getStats(route).getLeased());
@@ -337,7 +337,7 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         final HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         Assert.assertEquals(1, mgr.getTotalStats().getLeased());
         Assert.assertEquals(1, mgr.getStats(route).getLeased());
@@ -385,7 +385,7 @@ public class TestConnectionManagement ex
             new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
 
         HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
@@ -457,7 +457,7 @@ public class TestConnectionManagement ex
         abortingThread.start();
 
         try {
-            mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+            mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
             Assert.fail("expected SocketException");
         } catch(final SocketException expected) {}
 
@@ -511,7 +511,7 @@ public class TestConnectionManagement ex
         abortingThread.start();
 
         try {
-            mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+            mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
             Assert.fail("IOException expected");
         } catch(final IOException expected) {
         }
@@ -566,7 +566,7 @@ public class TestConnectionManagement ex
         abortingThread.start();
 
         try {
-            mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), 0, context);
+            mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
             Assert.fail("IOException expected");
         } catch(final IOException expected) {
         }



Mime
View raw message