hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1411674 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/examples/org/apache/http/examples/nio/ httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/ httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/ httpcore-nio/src/test/...
Date Tue, 20 Nov 2012 14:17:13 GMT
Author: olegk
Date: Tue Nov 20 14:17:11 2012
New Revision: 1411674

URL: http://svn.apache.org/viewvc?rev=1411674&view=rev
Log:
Removed connect timeout attribute from ConnectionConfig. Connect timeout should be a request
level attribute

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/ConnectionConfig.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamConfig.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
Tue Nov 20 14:17:11 2012
@@ -852,8 +852,8 @@ public class NHttpReverseProxy {
         public ProxyConnPool(
                 final ConnectingIOReactor ioreactor,
                 final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
-                final ConnectionConfig config) {
-            super(ioreactor, connFactory, config);
+                final int connectTimeout) {
+            super(ioreactor, connFactory, connectTimeout);
         }
 
         @Override

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
Tue Nov 20 14:17:11 2012
@@ -40,7 +40,7 @@ import org.apache.http.nio.NHttpClientCo
 import org.apache.http.nio.pool.AbstractNIOConnPool;
 import org.apache.http.nio.pool.NIOConnFactory;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
-import org.apache.http.params.HttpParamConfig;
+import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.pool.ConnPool;
 import org.apache.http.util.Args;
@@ -61,7 +61,7 @@ public class BasicNIOConnPool extends Ab
 
     private static AtomicLong COUNTER = new AtomicLong();
 
-    private final ConnectionConfig config;
+    private final int connectTimeout;
 
     /**
      * @deprecated (4.3) use {@link BasicNIOConnPool#BasicNIOConnPool(ConnectingIOReactor,
@@ -74,7 +74,7 @@ public class BasicNIOConnPool extends Ab
             final HttpParams params) {
         super(ioreactor, connFactory, 2, 20);
         Args.notNull(params, "HTTP parameters");
-        this.config = HttpParamConfig.getConnectionConfig(params);
+        this.connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
     }
 
     /**
@@ -93,17 +93,28 @@ public class BasicNIOConnPool extends Ab
     public BasicNIOConnPool(
             final ConnectingIOReactor ioreactor,
             final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
-            final ConnectionConfig config) {
+            final int connectTimeout) {
         super(ioreactor, connFactory, 2, 20);
-        this.config = config != null ? config : ConnectionConfig.DEFAULT;
+        this.connectTimeout = connectTimeout;
     }
 
     /**
      * @since 4.3
      */
     public BasicNIOConnPool(
-            final ConnectingIOReactor ioreactor, final ConnectionConfig config) {
-        this(ioreactor, new BasicNIOConnFactory(config), config);
+            final ConnectingIOReactor ioreactor,
+            final int connectTimeout,
+            final ConnectionConfig config) {
+        this(ioreactor, new BasicNIOConnFactory(config), connectTimeout);
+    }
+
+    /**
+     * @since 4.3
+     */
+    public BasicNIOConnPool(
+            final ConnectingIOReactor ioreactor,
+            final ConnectionConfig config) {
+        this(ioreactor, new BasicNIOConnFactory(config), 0);
     }
 
     @Override
@@ -127,7 +138,7 @@ public class BasicNIOConnPool extends Ab
             final Object state,
             final FutureCallback<BasicNIOPoolEntry> callback) {
         return super.lease(route, state,
-                this.config.getConnectTimeout(), TimeUnit.MILLISECONDS, callback);
+                this.connectTimeout, TimeUnit.MILLISECONDS, callback);
     }
 
     @Override
@@ -135,7 +146,7 @@ public class BasicNIOConnPool extends Ab
             final HttpHost route,
             final Object state) {
         return super.lease(route, state,
-                this.config.getConnectTimeout(), TimeUnit.MILLISECONDS, null);
+                this.connectTimeout, TimeUnit.MILLISECONDS, null);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
Tue Nov 20 14:17:11 2012
@@ -51,7 +51,7 @@ public class TestBasicNIOConnPool {
 
         route = new HttpHost("localhost", 80, "http");
         connFactory = new BasicNIOConnFactory(ConnectionConfig.DEFAULT);
-        pool = new BasicNIOConnPool(reactor, connFactory, ConnectionConfig.DEFAULT);
+        pool = new BasicNIOConnPool(reactor, connFactory, 0);
     }
 
     @After

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
Tue Nov 20 14:17:11 2012
@@ -39,7 +39,6 @@ import org.apache.http.HttpRequestInterc
 import org.apache.http.HttpResponse;
 import org.apache.http.concurrent.BasicFuture;
 import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.config.ConnectionConfig;
 import org.apache.http.impl.nio.DefaultHttpClientIODispatch;
 import org.apache.http.impl.nio.DefaultNHttpClientConnection;
 import org.apache.http.impl.nio.pool.BasicNIOConnFactory;
@@ -96,8 +95,7 @@ public class HttpClientNio {
         super();
         this.ioReactor = new DefaultConnectingIOReactor();
         this.connFactory = connFactory;
-        this.connpool = new BasicNIOConnPool(this.ioReactor, new BasicNIOConnFactory(connFactory),
-                ConnectionConfig.DEFAULT);
+        this.connpool = new BasicNIOConnPool(this.ioReactor, new BasicNIOConnFactory(connFactory),
0);
     }
 
     public int getTimeout() {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/ConnectionConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/ConnectionConfig.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/ConnectionConfig.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/config/ConnectionConfig.java
Tue Nov 20 14:17:11 2012
@@ -43,30 +43,23 @@ public class ConnectionConfig implements
 
     public static final ConnectionConfig DEFAULT = new Builder().build();
 
-    private final int connectTimeout;
     private final Charset charset;
     private final CodingErrorAction malformedInputAction;
     private final CodingErrorAction unmappableInputAction;
     private final MessageConstraints messageConstraints;
 
     ConnectionConfig(
-            final int connectTimeout,
             final Charset charset,
             final CodingErrorAction malformedInputAction,
             final CodingErrorAction unmappableInputAction,
             final MessageConstraints messageConstraints) {
         super();
-        this.connectTimeout = connectTimeout;
         this.charset = charset;
         this.malformedInputAction = malformedInputAction;
         this.unmappableInputAction = unmappableInputAction;
         this.messageConstraints = messageConstraints;
     }
 
-    public int getConnectTimeout() {
-        return connectTimeout;
-    }
-
     public Charset getCharset() {
         return charset;
     }
@@ -91,8 +84,7 @@ public class ConnectionConfig implements
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
-        builder.append("[connectTimeout=").append(this.connectTimeout)
-                .append(", charset=").append(this.charset)
+        builder.append("[charset=").append(this.charset)
                 .append(", malformedInputAction=").append(this.malformedInputAction)
                 .append(", unmappableInputAction=").append(this.unmappableInputAction)
                 .append(", messageConstraints=").append(this.messageConstraints)
@@ -106,7 +98,6 @@ public class ConnectionConfig implements
 
     public static class Builder {
 
-        private int connectTimeout;
         private Charset charset;
         private CodingErrorAction malformedInputAction;
         private CodingErrorAction unmappableInputAction;
@@ -145,18 +136,12 @@ public class ConnectionConfig implements
             return this;
         }
 
-        public Builder setConnectTimeout(int connectTimeout) {
-            this.connectTimeout = connectTimeout;
-            return this;
-        }
-
         public ConnectionConfig build() {
             Charset cs = charset;
             if (cs == null && (malformedInputAction != null || unmappableInputAction
!= null)) {
                 cs = Consts.ASCII;
             }
             return new ConnectionConfig(
-                    connectTimeout,
                     charset,
                     malformedInputAction,
                     unmappableInputAction,

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
Tue Nov 20 14:17:11 2012
@@ -43,6 +43,7 @@ import org.apache.http.config.Connection
 import org.apache.http.config.SocketConfig;
 import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParamConfig;
 import org.apache.http.params.HttpParams;
 import org.apache.http.pool.ConnFactory;
@@ -60,6 +61,7 @@ import org.apache.http.util.Args;
 public class BasicConnFactory implements ConnFactory<HttpHost, HttpClientConnection>
{
 
     private final SSLSocketFactory sslfactory;
+    private final int connectTimeout;
     private final SocketConfig sconfig;
     private final ConnectionConfig cconfig;
 
@@ -72,6 +74,7 @@ public class BasicConnFactory implements
         super();
         Args.notNull(params, "HTTP params");
         this.sslfactory = sslfactory;
+        this.connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
         this.sconfig = HttpParamConfig.getSocketConfig(params);
         this.cconfig = HttpParamConfig.getConnectionConfig(params);
     }
@@ -89,9 +92,13 @@ public class BasicConnFactory implements
      * @since 4.3
      */
     public BasicConnFactory(
-            final SSLSocketFactory sslfactory, final SocketConfig sconfig, final ConnectionConfig
cconfig) {
+            final SSLSocketFactory sslfactory,
+            final int connectTimeout,
+            final SocketConfig sconfig,
+            final ConnectionConfig cconfig) {
         super();
         this.sslfactory = sslfactory;
+        this.connectTimeout = connectTimeout;
         this.sconfig = sconfig != null ? sconfig : SocketConfig.DEFAULT;
         this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
     }
@@ -99,15 +106,23 @@ public class BasicConnFactory implements
     /**
      * @since 4.3
      */
+    public BasicConnFactory(
+            final int connectTimeout, final SocketConfig sconfig, final ConnectionConfig
cconfig) {
+        this(null, connectTimeout, sconfig, cconfig);
+    }
+
+    /**
+     * @since 4.3
+     */
     public BasicConnFactory(final SocketConfig sconfig, final ConnectionConfig cconfig) {
-        this(null, sconfig, cconfig);
+        this(null, 0, sconfig, cconfig);
     }
 
     /**
      * @since 4.3
      */
     public BasicConnFactory() {
-        this(null, SocketConfig.DEFAULT, ConnectionConfig.DEFAULT);
+        this(null, 0, SocketConfig.DEFAULT, ConnectionConfig.DEFAULT);
     }
 
     /**
@@ -135,7 +150,7 @@ public class BasicConnFactory implements
             throw new IOException(scheme + " scheme is not supported");
         }
         socket.setSoTimeout(this.sconfig.getSoTimeout());
-        socket.connect(new InetSocketAddress(host.getHostName(), host.getPort()), this.cconfig.getConnectTimeout());
+        socket.connect(new InetSocketAddress(host.getHostName(), host.getPort()), this.connectTimeout);
         socket.setTcpNoDelay(this.sconfig.isTcpNoDelay());
         int linger = this.sconfig.getSoLinger();
         if (linger >= 0) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamConfig.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamConfig.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamConfig.java
Tue Nov 20 14:17:11 2012
@@ -66,7 +66,6 @@ public final class HttpParamConfig {
         MessageConstraints messageConstraints = getMessageConstraints(params);
         String csname = HttpProtocolParams.getHttpElementCharset(params);
         return ConnectionConfig.custom()
-                .setConnectTimeout(HttpConnectionParams.getConnectionTimeout(params))
                 .setCharset(csname != null ? Charset.forName(csname) : null)
                 .setMalformedInputAction((CodingErrorAction)
                         params.getParameter(CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION))

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java?rev=1411674&r1=1411673&r2=1411674&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java
Tue Nov 20 14:17:11 2012
@@ -96,8 +96,9 @@ public class TestBasicConnPool {
     @Test
     public void testHttpsCreateConnection() throws Exception {
         SocketConfig sconfig = SocketConfig.custom().setSoTimeout(100).build();
-        connFactory = new BasicConnFactory((SSLSocketFactory)SSLSocketFactory.getDefault(),
-                sconfig, ConnectionConfig.DEFAULT);
+        connFactory = new BasicConnFactory(
+                (SSLSocketFactory)SSLSocketFactory.getDefault(),
+                0, sconfig, ConnectionConfig.DEFAULT);
         host = new HttpHost("localhost", sslServerPort, "https");
         conn = connFactory.create(host);
 



Mime
View raw message