hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1414675 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/client/utils/ main/java/org/apache/http/conn/ main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/conn/ test/java/org/apache/http/imp...
Date Wed, 28 Nov 2012 13:36:45 GMT
Author: olegk
Date: Wed Nov 28 13:36:41 2012
New Revision: 1414675

URL: http://svn.apache.org/viewvc?rev=1414675&view=rev
Log:
Updated new connection managers to use SocketClientConnectionImpl instead of deprecated DefaultClientConnection

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java
  (contents, props changed)
      - copied, changed from r1414674, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpSSLConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java
  (contents, props changed)
      - copied, changed from r1414674, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ClientConnectionImpl.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpSSLConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ClientConnectionImpl.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionManagerBase.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionManagerBase.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
Wed Nov 28 13:36:41 2012
@@ -188,7 +188,7 @@ public class URLEncodedUtils {
         if (s == null) {
             return Collections.emptyList();
         }
-        BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
+        BasicHeaderValueParser parser = BasicHeaderValueParser.INSTANCE;
         CharArrayBuffer buffer = new CharArrayBuffer(s.length());
         buffer.append(s);
         ParserCursor cursor = new ParserCursor(0, buffer.length());

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
Wed Nov 28 13:36:41 2012
@@ -49,7 +49,7 @@ import org.apache.http.conn.routing.Http
  */
 @Deprecated
 public interface ManagedClientConnection extends
-    HttpClientConnection, HttpRoutedConnection, HttpSSLConnection, ConnectionReleaseTrigger
{
+    HttpClientConnection, HttpRoutedConnection, SocketClientConnection, ConnectionReleaseTrigger
{
 
     /**
      * Indicates whether this connection is secure.

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java
(from r1414674, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpSSLConnection.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpSSLConnection.java&r1=1414674&r2=1414675&rev=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpSSLConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java
Wed Nov 28 13:36:41 2012
@@ -27,16 +27,24 @@
 
 package org.apache.http.conn;
 
+import java.io.IOException;
+import java.net.Socket;
+
 import javax.net.ssl.SSLSession;
 
+import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpInetConnection;
 
 /**
- * Extended interface that exposes SSL session details.
+ * Extended interface that exposes {@link Socket} bind method and SSL session details.
  *
  * @since 4.3
  */
-public interface HttpSSLConnection extends HttpInetConnection {
+public interface SocketClientConnection extends HttpClientConnection, HttpInetConnection
{
+
+    void bind(Socket socket) throws IOException;
+
+    Socket getSocket();
 
     /**
      * Obtains the SSL session of the underlying connection, if any.

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

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
Wed Nov 28 13:36:41 2012
@@ -37,7 +37,7 @@ import org.apache.http.auth.AuthState;
 import org.apache.http.auth.Credentials;
 import org.apache.http.client.UserTokenHandler;
 import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.conn.HttpSSLConnection;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 
@@ -76,8 +76,8 @@ public class DefaultUserTokenHandler imp
         if (userPrincipal == null) {
             HttpConnection conn = (HttpConnection) context.getAttribute(
                     ExecutionContext.HTTP_CONNECTION);
-            if (conn instanceof HttpSSLConnection) {
-                SSLSession sslsession = ((HttpSSLConnection) conn).getSSLSession();
+            if (conn instanceof SocketClientConnection) {
+                SSLSession sslsession = ((SocketClientConnection) conn).getSSLSession();
                 if (sslsession != null) {
                     userPrincipal = sslsession.getLocalPrincipal();
                 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
Wed Nov 28 13:36:41 2012
@@ -266,6 +266,18 @@ public abstract class AbstractClientConn
         return conn.isSecure();
     }
 
+    public void bind(Socket socket) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Socket getSocket() {
+        OperatedClientConnection conn = getWrappedConnection();
+        assertValid(conn);
+        if (!isOpen())
+            return null;
+        return conn.getSocket();
+    }
+
     public SSLSession getSSLSession() {
         OperatedClientConnection conn = getWrappedConnection();
         assertValid(conn);

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=1414675&r1=1414674&r2=1414675&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 Nov 28 13:36:41 2012
@@ -42,6 +42,7 @@ import org.apache.http.conn.ConnectionRe
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.HttpConnectionFactory;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.params.HttpParams;
@@ -70,10 +71,10 @@ public class BasicHttpClientConnectionMa
     private final Log log = LogFactory.getLog(getClass());
 
     private final HttpClientConnectionOperator connectionOperator;
-    private final HttpConnectionFactory<DefaultClientConnection> connFactory;
+    private final HttpConnectionFactory<SocketClientConnection> connFactory;
 
     @GuardedBy("this")
-    private DefaultClientConnection conn;
+    private SocketClientConnection conn;
 
     @GuardedBy("this")
     private HttpRoute route;
@@ -96,7 +97,7 @@ public class BasicHttpClientConnectionMa
     public BasicHttpClientConnectionManager(
             final SchemeRegistry schemeRegistry,
             final DnsResolver dnsResolver,
-            final HttpConnectionFactory<DefaultClientConnection> connFactory) {
+            final HttpConnectionFactory<SocketClientConnection> connFactory) {
         if (schemeRegistry == null) {
             throw new IllegalArgumentException("Scheme registry may not be null");
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
Wed Nov 28 13:36:41 2012
@@ -34,6 +34,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.AbstractConnPool;
 import org.apache.http.pool.ConnFactory;
@@ -42,7 +43,7 @@ import org.apache.http.pool.ConnFactory;
  * @since 4.3
  */
 @ThreadSafe
-class CPool extends AbstractConnPool<HttpRoute, DefaultClientConnection, CPoolEntry>
{
+class CPool extends AbstractConnPool<HttpRoute, SocketClientConnection, CPoolEntry>
{
 
     private static AtomicLong COUNTER = new AtomicLong();
 
@@ -59,15 +60,15 @@ class CPool extends AbstractConnPool<Htt
     }
 
     @Override
-    protected CPoolEntry createEntry(final HttpRoute route, final DefaultClientConnection
conn) {
+    protected CPoolEntry createEntry(final HttpRoute route, final SocketClientConnection
conn) {
         String id = Long.toString(COUNTER.getAndIncrement());
         return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
     }
 
-    static class InternalConnFactory implements ConnFactory<HttpRoute, DefaultClientConnection>
{
+    static class InternalConnFactory implements ConnFactory<HttpRoute, SocketClientConnection>
{
 
-        public DefaultClientConnection create(final HttpRoute route) throws IOException {
-            return new DefaultClientConnection();
+        public SocketClientConnection create(final HttpRoute route) throws IOException {
+            return new SocketClientConnectionImpl(8 * 1024);
         }
 
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
Wed Nov 28 13:36:41 2012
@@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.PoolEntry;
 
@@ -40,7 +41,7 @@ import org.apache.http.pool.PoolEntry;
  * @since 4.3
  */
 @ThreadSafe
-class CPoolEntry extends PoolEntry<HttpRoute, DefaultClientConnection> {
+class CPoolEntry extends PoolEntry<HttpRoute, SocketClientConnection> {
 
     private final Log log;
 
@@ -48,7 +49,7 @@ class CPoolEntry extends PoolEntry<HttpR
             final Log log,
             final String id,
             final HttpRoute route,
-            final DefaultClientConnection conn,
+            final SocketClientConnection conn,
             final long timeToLive, final TimeUnit tunit) {
         super(id, route, conn, timeToLive, tunit);
         this.log = log;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
Wed Nov 28 13:36:41 2012
@@ -34,7 +34,7 @@ import java.lang.reflect.Proxy;
 
 import org.apache.http.HttpClientConnection;
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.conn.HttpSSLConnection;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.protocol.HttpContext;
 
 /**
@@ -137,7 +137,7 @@ class CPoolProxy implements InvocationHa
             final CPoolEntry poolEntry) {
         return (HttpClientConnection) Proxy.newProxyInstance(
                 CPoolProxy.class.getClassLoader(),
-                new Class<?>[] { HttpClientConnection.class, HttpSSLConnection.class,
HttpContext.class },
+                new Class<?>[] { HttpClientConnection.class, SocketClientConnection.class,
HttpContext.class },
                 new CPoolProxy(poolEntry));
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
Wed Nov 28 13:36:41 2012
@@ -46,6 +46,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
+import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HttpContext;
@@ -54,7 +55,7 @@ import org.apache.http.io.HttpMessagePar
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.io.SessionOutputBuffer;
 
-import org.apache.http.conn.HttpSSLConnection;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.OperatedClientConnection;
 
 /**
@@ -62,13 +63,12 @@ import org.apache.http.conn.OperatedClie
  *
  * @since 4.0
  *
- * @deprecated (4.3) deprecated in favor of {@link ClientConnectionImpl}.
+ * @deprecated (4.3) deprecated in favor of {@link SocketClientConnectionImpl}.
  */
-@SuppressWarnings("deprecation")
 @NotThreadSafe // connSecure, targetHost
 @Deprecated
 public class DefaultClientConnection extends SocketHttpClientConnection
-    implements OperatedClientConnection, HttpSSLConnection, HttpContext {
+    implements OperatedClientConnection, SocketClientConnection, HttpContext {
 
     private final Log log = LogFactory.getLog(getClass());
     private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
@@ -231,6 +231,10 @@ public class DefaultClientConnection ext
             (buffer, null, responseFactory, params);
     }
 
+    public void bind(Socket socket) throws IOException {
+        bind(socket, new BasicHttpParams());
+    }
+
     public void update(Socket sock, HttpHost target,
                        boolean secure, HttpParams params)
         throws IOException {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
Wed Nov 28 13:36:41 2012
@@ -28,18 +28,19 @@
 package org.apache.http.impl.conn;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.HttpConnectionFactory;
 
 /**
  * @since 4.3
  */
 @Immutable
-public class DefaultClientConnectionFactory implements HttpConnectionFactory<DefaultClientConnection>
{
+public class DefaultClientConnectionFactory implements HttpConnectionFactory<SocketClientConnection>
{
 
     public static final DefaultClientConnectionFactory INSTANCE = new DefaultClientConnectionFactory();
 
-    public DefaultClientConnection create() {
-        return new DefaultClientConnection();
+    public SocketClientConnection create() {
+        return new SocketClientConnectionImpl(8 * 1024);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionManagerBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionManagerBase.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionManagerBase.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionManagerBase.java
Wed Nov 28 13:36:41 2012
@@ -40,6 +40,7 @@ import org.apache.http.conn.ConnectionPo
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.params.HttpParams;
@@ -165,7 +166,7 @@ abstract class HttpClientConnectionManag
             if (entry == null) {
                 return;
             }
-            DefaultClientConnection conn = entry.getConnection();
+            SocketClientConnection conn = entry.getConnection();
             try {
                 if (conn.isOpen()) {
                     entry.setState(state);
@@ -188,7 +189,7 @@ abstract class HttpClientConnectionManag
         if (managedConn == null) {
             throw new IllegalArgumentException("Connection may not be null");
         }
-        DefaultClientConnection conn;
+        SocketClientConnection conn;
         synchronized (managedConn) {
             CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
             conn = entry.getConnection();
@@ -204,7 +205,7 @@ abstract class HttpClientConnectionManag
         if (managedConn == null) {
             throw new IllegalArgumentException("Connection may not be null");
         }
-        DefaultClientConnection conn;
+        SocketClientConnection conn;
         synchronized (managedConn) {
             CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
             conn = entry.getConnection();

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
Wed Nov 28 13:36:41 2012
@@ -42,6 +42,7 @@ import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.HttpHostConnectException;
 import org.apache.http.conn.HttpInetSocketAddress;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -86,7 +87,7 @@ class HttpClientConnectionOperator {
     }
 
     public void connect(
-            final DefaultClientConnection conn,
+            final SocketClientConnection conn,
             final HttpHost host,
             final InetAddress local,
             final HttpContext context,
@@ -102,7 +103,7 @@ class HttpClientConnectionOperator {
             boolean last = i == addresses.length - 1;
 
             Socket sock = sf.createSocket(params);
-            conn.opening(sock, host);
+            conn.bind(sock);
 
             InetSocketAddress remoteAddress = new HttpInetSocketAddress(host, address, port);
             InetSocketAddress localAddress = null;
@@ -114,11 +115,7 @@ class HttpClientConnectionOperator {
             }
             try {
                 Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
-                if (sock != connsock) {
-                    sock = connsock;
-                    conn.opening(sock, host);
-                }
-                conn.openCompleted(sf.isSecure(sock), params);
+                conn.bind(connsock);
                 return;
             } catch (ConnectException ex) {
                 if (last) {
@@ -137,7 +134,7 @@ class HttpClientConnectionOperator {
     }
 
     public void upgrade(
-            final DefaultClientConnection conn,
+            final SocketClientConnection conn,
             final HttpHost host,
             final HttpContext context,
             final HttpParams params) throws IOException {
@@ -157,7 +154,7 @@ class HttpClientConnectionOperator {
         } catch (ConnectException ex) {
             throw new HttpHostConnectException(host, ex);
         }
-        conn.update(sock, host, lsf.isSecure(sock), params);
+        conn.bind(sock);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
Wed Nov 28 13:36:41 2012
@@ -234,6 +234,15 @@ class ManagedClientConnectionImpl implem
         return conn.isSecure();
     }
 
+    public void bind(Socket socket) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Socket getSocket() {
+        OperatedClientConnection conn = ensureConnection();
+        return conn.getSocket();
+    }
+
     public SSLSession getSSLSession() {
         OperatedClientConnection conn = ensureConnection();
         SSLSession result = null;

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java
(from r1414674, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ClientConnectionImpl.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ClientConnectionImpl.java&r1=1414674&r2=1414675&rev=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ClientConnectionImpl.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java
Wed Nov 28 13:36:41 2012
@@ -29,24 +29,33 @@ package org.apache.http.impl.conn;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InterruptedIOException;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.config.MessageConstraints;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.io.HttpMessageParserFactory;
 import org.apache.http.io.HttpMessageWriterFactory;
+import org.apache.http.protocol.HttpContext;
 
-class ClientConnectionImpl extends DefaultBHttpClientConnection {
+class SocketClientConnectionImpl extends DefaultBHttpClientConnection
+                                 implements SocketClientConnection, HttpContext {
 
     private static final AtomicLong COUNT = new AtomicLong();
 
@@ -54,8 +63,11 @@ class ClientConnectionImpl extends Defau
     private final Log log;
     private final Log headerlog;
     private final Wire wire;
+    private final Map<String, Object> attributes;
+
+    private volatile boolean shutdown;
 
-    public ClientConnectionImpl(
+    public SocketClientConnectionImpl(
             int buffersize,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
@@ -71,9 +83,10 @@ class ClientConnectionImpl extends Defau
         this.log = LogFactory.getLog(getClass());
         this.headerlog = LogFactory.getLog("org.apache.http.headers");
         this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
+        this.attributes = new ConcurrentHashMap<String, Object>();
     }
 
-    public ClientConnectionImpl(int buffersize) {
+    public SocketClientConnectionImpl(int buffersize) {
         this(buffersize, null, null, null, null, null, null, null);
     }
 
@@ -90,6 +103,7 @@ class ClientConnectionImpl extends Defau
         if (this.log.isDebugEnabled()) {
             this.log.debug(this.id + ": Shutdown connection");
         }
+        this.shutdown = true;
         super.shutdown();
     }
 
@@ -133,4 +147,40 @@ class ClientConnectionImpl extends Defau
         }
     }
 
+    public Object getAttribute(final String id) {
+        return this.attributes.get(id);
+    }
+
+    public Object removeAttribute(final String id) {
+        return this.attributes.remove(id);
+    }
+
+    public void setAttribute(final String id, final Object obj) {
+        this.attributes.put(id, obj);
+    }
+
+    @Override
+    public void bind(final Socket socket) throws IOException {
+        if (this.shutdown) {
+            socket.close(); // allow this to throw...
+            // ...but if it doesn't, explicitly throw one ourselves.
+            throw new InterruptedIOException("Connection already shutdown");
+        }
+        super.bind(socket);
+    }
+
+    @Override
+    public Socket getSocket() {
+        return super.getSocket();
+    }
+
+    public SSLSession getSSLSession() {
+        Socket socket = super.getSocket();
+        if (socket instanceof SSLSocket) {
+            return ((SSLSocket) socket).getSession();
+        } else {
+            return null;
+        }
+    }
+
 }

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

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

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

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=1414675&r1=1414674&r2=1414675&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 Nov 28 13:36:41 2012
@@ -522,9 +522,8 @@ public class TestConnectionManagement ex
 
         try {
             mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), context, params);
-            Assert.fail("expected exception");
+            Assert.fail("IOException expected");
         } catch(IOException expected) {
-            Assert.assertEquals("Connection already shutdown", expected.getMessage());
         }
 
         abortingThread.join(5000);
@@ -578,8 +577,9 @@ public class TestConnectionManagement ex
 
         try {
             mgr.connect(conn, route.getTargetHost(), route.getLocalAddress(), context, params);
-            Assert.fail("expected SocketException");
-        } catch(SocketException expected) {}
+            Assert.fail("IOException expected");
+        } catch(IOException expected) {
+        }
 
         abortingThread.join(5000);
         if(throwRef.get() != null)

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
Wed Nov 28 13:36:41 2012
@@ -35,6 +35,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpConnectionFactory;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -47,8 +48,8 @@ import org.mockito.Mockito;
 
 public class TestBasicHttpClientConnectionManager {
 
-    private DefaultClientConnection conn;
-    private HttpConnectionFactory<DefaultClientConnection> connFactory;
+    private SocketClientConnection conn;
+    private HttpConnectionFactory<SocketClientConnection> connFactory;
     private Socket socket;
     private SchemeSocketFactory plainSocketFactory;
     private SchemeRegistry schemeRegistry;
@@ -58,7 +59,7 @@ public class TestBasicHttpClientConnecti
     @SuppressWarnings("unchecked")
     @Before
     public void setup() throws Exception {
-        conn = Mockito.mock(DefaultClientConnection.class);
+        conn = Mockito.mock(SocketClientConnection.class);
         connFactory = Mockito.mock(HttpConnectionFactory.class);
         Mockito.when(connFactory.create()).thenReturn(conn);
         socket = Mockito.mock(Socket.class);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionManagerBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionManagerBase.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionManagerBase.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionManagerBase.java
Wed Nov 28 13:36:41 2012
@@ -38,6 +38,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.DnsResolver;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -51,7 +52,7 @@ import org.mockito.Mockito;
 
 public class TestHttpClientConnectionManagerBase {
 
-    private DefaultClientConnection conn;
+    private SocketClientConnection conn;
     private Socket socket;
     private SchemeSocketFactory plainSocketFactory;
     private SchemeRegistry schemeRegistry;
@@ -63,7 +64,7 @@ public class TestHttpClientConnectionMan
     @SuppressWarnings("unchecked")
     @Before
     public void setup() throws Exception {
-        conn = Mockito.mock(DefaultClientConnection.class);
+        conn = Mockito.mock(SocketClientConnection.class);
         socket = Mockito.mock(Socket.class);
         plainSocketFactory = Mockito.mock(SchemeSocketFactory.class);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpParams>any())).thenReturn(socket);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java?rev=1414675&r1=1414674&r2=1414675&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
Wed Nov 28 13:36:41 2012
@@ -35,6 +35,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpInetSocketAddress;
+import org.apache.http.conn.SocketClientConnection;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -49,7 +50,7 @@ import org.mockito.Mockito;
 
 public class TestHttpClientConnectionOperator {
 
-    private DefaultClientConnection conn;
+    private SocketClientConnection conn;
     private Socket socket;
     private SchemeSocketFactory plainSocketFactory;
     private SchemeLayeredSocketFactory sslSocketFactory;
@@ -59,7 +60,7 @@ public class TestHttpClientConnectionOpe
 
     @Before
     public void setup() throws Exception {
-        conn = Mockito.mock(DefaultClientConnection.class);
+        conn = Mockito.mock(SocketClientConnection.class);
         socket = Mockito.mock(Socket.class);
         plainSocketFactory = Mockito.mock(SchemeSocketFactory.class);
         sslSocketFactory = Mockito.mock(SchemeLayeredSocketFactory.class);
@@ -97,8 +98,7 @@ public class TestHttpClientConnectionOpe
         Mockito.verify(plainSocketFactory).connectSocket(socket,
                 new InetSocketAddress(ip1, 80),
                 new InetSocketAddress(local, 0), params);
-        Mockito.verify(conn).opening(socket, host);
-        Mockito.verify(conn).openCompleted(false, params);
+        Mockito.verify(conn, Mockito.times(2)).bind(socket);
     }
 
     @Test(expected=ConnectTimeoutException.class)
@@ -146,8 +146,7 @@ public class TestHttpClientConnectionOpe
         Mockito.verify(plainSocketFactory).connectSocket(socket,
                 new HttpInetSocketAddress(host, ip2, 80),
                 new InetSocketAddress(local, 0), params);
-        Mockito.verify(conn, Mockito.times(2)).opening(socket, host);
-        Mockito.verify(conn).openCompleted(false, params);
+        Mockito.verify(conn, Mockito.times(3)).bind(socket);
     }
 
     @Test
@@ -164,7 +163,7 @@ public class TestHttpClientConnectionOpe
 
         connectionOperator.upgrade(conn, host, context, params);
 
-        Mockito.verify(conn).update(socket, host, false, params);
+        Mockito.verify(conn).bind(socket);
     }
 
     @Test(expected=IllegalArgumentException.class)



Mime
View raw message