hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1585663 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/conn/ test/java/org/apache/http/impl/conn/
Date Tue, 08 Apr 2014 08:25:35 GMT
Author: olegk
Date: Tue Apr  8 08:25:34 2014
New Revision: 1585663

URL: http://svn.apache.org/r1585663
Log:
Delegate decision about null target host to route planners

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java?rev=1585663&r1=1585662&r2=1585663&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
Tue Apr  8 08:25:34 2014
@@ -66,7 +66,6 @@ import org.apache.http.params.HttpParams
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
 
 /**
  * Internal class.
@@ -122,7 +121,6 @@ class InternalHttpClient extends Closeab
         if (host == null) {
             host = (HttpHost) request.getParams().getParameter(ClientPNames.DEFAULT_HOST);
         }
-        Asserts.notNull(host, "Target host");
         return this.routePlanner.determineRoute(host, request, context);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java?rev=1585663&r1=1585662&r2=1585663&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
Tue Apr  8 08:25:34 2014
@@ -32,6 +32,7 @@ import java.net.InetAddress;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
+import org.apache.http.ProtocolException;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.protocol.HttpClientContext;
@@ -64,8 +65,10 @@ public class DefaultRoutePlanner impleme
             final HttpHost host,
             final HttpRequest request,
             final HttpContext context) throws HttpException {
-        Args.notNull(host, "Target host");
         Args.notNull(request, "Request");
+        if (host == null) {
+            throw new ProtocolException("Target host is not specified");
+        }
         final HttpClientContext clientContext = HttpClientContext.adapt(context);
         final RequestConfig config = clientContext.getRequestConfig();
         final InetAddress local = config.getLocalAddress();

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java?rev=1585663&r1=1585662&r2=1585663&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java
Tue Apr  8 08:25:34 2014
@@ -30,6 +30,7 @@ package org.apache.http.impl.conn;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.conn.SchemePortResolver;
@@ -102,4 +103,12 @@ public class TestDefaultRoutePlanner {
         Mockito.verify(schemePortResolver, Mockito.never()).resolve(Mockito.<HttpHost>any());
     }
 
+    @Test(expected= ProtocolException.class)
+    public void testNullTarget() throws Exception {
+        final HttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+
+        final HttpContext context = new BasicHttpContext();
+        routePlanner.determineRoute(null, request, context);
+    }
+
 }



Mime
View raw message