hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1483265 - in /httpcomponents/httpclient/trunk: fluent-hc/src/main/java/org/apache/http/client/fluent/ httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ httpclient/src/main/java/org/apache/http/conn/ssl/ httpclient/src/main/...
Date Thu, 16 May 2013 09:12:42 GMT
Author: olegk
Date: Thu May 16 09:12:42 2013
New Revision: 1483265

URL: http://svn.apache.org/r1483265
Log:
Code cleanups

Modified:
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.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/main/java/org/apache/http/impl/execchain/ProtocolExec.java

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java?rev=1483265&r1=1483264&r2=1483265&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
(original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
Thu May 16 09:12:42 2013
@@ -45,7 +45,7 @@ import org.apache.http.client.CookieStor
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
@@ -207,9 +207,9 @@ public class Executor {
      */
     public Response execute(
             final Request request) throws ClientProtocolException, IOException {
-        this.localContext.setAttribute(ClientContext.CREDS_PROVIDER, this.credentialsProvider);
-        this.localContext.setAttribute(ClientContext.AUTH_CACHE, this.authCache);
-        this.localContext.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
+        this.localContext.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credentialsProvider);
+        this.localContext.setAttribute(HttpClientContext.AUTH_CACHE, this.authCache);
+        this.localContext.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
         final HttpRequestBase httprequest = request.getHttpRequest();
         httprequest.reset();
         return new Response(this.httpclient.execute(httprequest, this.localContext));

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java?rev=1483265&r1=1483264&r2=1483265&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java
Thu May 16 09:12:42 2013
@@ -119,6 +119,7 @@ public class CachingHttpClientBuilder ex
         return null;
     }
 
+    @SuppressWarnings("resource")
     private SchedulingStrategy createSchedulingStrategy(final CacheConfig config) {
         return schedulingStrategy != null ? schedulingStrategy : new ImmediateSchedulingStrategy(config);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1483265&r1=1483264&r2=1483265&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Thu May 16 09:12:42 2013
@@ -551,13 +551,14 @@ public class SSLSocketFactory implements
             final HttpContext context) throws IOException, ConnectTimeoutException {
         Args.notNull(host, "HTTP host");
         Args.notNull(remoteAddress, "Remote address");
-        Socket sock = socket != null ? socket : createSocket(context);
+        final Socket sock = socket != null ? socket : createSocket(context);
         if (localAddress != null) {
             sock.bind(localAddress);
         }
         try {
             sock.connect(remoteAddress, connectTimeout);
         } catch (final SocketTimeoutException ex) {
+            closeSocket(sock);
             throw new ConnectTimeoutException(host, remoteAddress);
         }
         // Setup SSL layering if necessary
@@ -565,10 +566,17 @@ public class SSLSocketFactory implements
             final SSLSocket sslsock = (SSLSocket) sock;
             sslsock.startHandshake();
             verifyHostname(sslsock, host.getHostName());
+            return sock;
         } else {
-            sock = createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(),
context);
+            return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(),
context);
+        }
+    }
+
+    private void closeSocket(final Socket sock) {
+        try {
+            sock.close();
+        } catch (final IOException ignore) {
         }
-        return sock;
     }
 
     public Socket createLayeredSocket(

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java?rev=1483265&r1=1483264&r2=1483265&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
Thu May 16 09:12:42 2013
@@ -456,6 +456,7 @@ public class HttpClientBuilder {
                     }
                 }
             }
+            @SuppressWarnings("resource")
             final PoolingHttpClientConnectionManager poolingmgr = new PoolingHttpClientConnectionManager(
                     RegistryBuilder.<ConnectionSocketFactory>create()
                         .register("http", PlainSocketFactory.getSocketFactory())

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java?rev=1483265&r1=1483264&r2=1483265&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
Thu May 16 09:12:42 2013
@@ -78,12 +78,10 @@ public class BrowserCompatSpec extends C
     };
 
     private final String[] datepatterns;
-    private final BrowserCompatSpecFactory.SecurityLevel securityLevel;
 
     /** Default constructor */
     public BrowserCompatSpec(final String[] datepatterns, final BrowserCompatSpecFactory.SecurityLevel
securityLevel) {
         super();
-        this.securityLevel = securityLevel;
         if (datepatterns != null) {
             this.datepatterns = datepatterns.clone();
         } else {

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=1483265&r1=1483264&r2=1483265&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
Thu May 16 09:12:42 2013
@@ -194,7 +194,7 @@ public class MainClientExec implements C
         try {
             if (execAware != null) {
                 if (execAware.isAborted()) {
-                    connHolder.abortConnection();
+                    connHolder.close();
                     throw new RequestAbortedException("Request aborted");
                 } else {
                     execAware.setCancellable(connHolder);

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=1483265&r1=1483264&r2=1483265&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
Thu May 16 09:12:42 2013
@@ -141,7 +141,7 @@ public class MinimalClientExec implement
         try {
             if (execAware != null) {
                 if (execAware.isAborted()) {
-                    releaseTrigger.abortConnection();
+                    releaseTrigger.close();
                     throw new RequestAbortedException("Request aborted");
                 } else {
                     execAware.setCancellable(releaseTrigger);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java?rev=1483265&r1=1483264&r2=1483265&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
Thu May 16 09:12:42 2013
@@ -45,13 +45,11 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.methods.HttpRequestWrapper;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.util.Args;
 
@@ -168,9 +166,9 @@ public class ProtocolExec implements Cli
         }
 
         // Run request protocol interceptors
-        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
-        context.setAttribute(ClientContext.ROUTE, route);
-        context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
+        context.setAttribute(HttpClientContext.HTTP_TARGET_HOST, target);
+        context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
+        context.setAttribute(HttpClientContext.HTTP_REQUEST, request);
 
         this.httpProcessor.process(request, context);
 
@@ -178,7 +176,7 @@ public class ProtocolExec implements Cli
             context, execAware);
         try {
             // Run response protocol interceptors
-            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
+            context.setAttribute(HttpClientContext.HTTP_RESPONSE, response);
             this.httpProcessor.process(response, context);
             return response;
         } catch (final RuntimeException ex) {



Mime
View raw message