You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2014/04/30 11:31:52 UTC

svn commit: r1591220 - in /httpcomponents/httpclient/branches/4.3.x/httpclient/src: main/java/org/apache/http/client/utils/URIUtils.java test/java/org/apache/http/client/utils/TestURIUtils.java

Author: olegk
Date: Wed Apr 30 09:31:51 2014
New Revision: 1591220

URL: http://svn.apache.org/r1591220
Log:
HTTPCLIENT-1498: empty host in redirect location causes NPE

Modified:
    httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
    httpcomponents/httpclient/branches/4.3.x/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java?rev=1591220&r1=1591219&r2=1591220&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java Wed Apr 30 09:31:51 2014
@@ -366,7 +366,7 @@ public class URIUtils {
                 }
             }
             final String scheme = uri.getScheme();
-            if (host != null) {
+            if (!TextUtils.isBlank(host)) {
                 target = new HttpHost(host, port, scheme);
             }
         }

Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java?rev=1591220&r1=1591219&r2=1591220&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java Wed Apr 30 09:31:51 2014
@@ -229,6 +229,8 @@ public class TestURIUtils {
                 URIUtils.extractHost(new URI("http://localhost:8080;sessionid=stuff/abcd")));
         Assert.assertEquals(new HttpHost("localhost",-1),
                 URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
+        Assert.assertEquals(null,
+                URIUtils.extractHost(new URI("http://:80/robots.txt")));
     }
 
     @Test