hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1784127 - in /httpcomponents/httpcore/trunk/httpcore5/src: main/java/org/apache/hc/core5/http/HttpHost.java main/java/org/apache/hc/core5/util/Args.java test/java/org/apache/hc/core5/http/TestHttpHost.java
Date Thu, 23 Feb 2017 13:26:36 GMT
Author: olegk
Date: Thu Feb 23 13:26:36 2017
New Revision: 1784127

URL: http://svn.apache.org/viewvc?rev=1784127&view=rev
Log:
HTTPCORE-447: HttpHost#create does not throw IllegalArgumentException for empty string

Modified:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java?rev=1784127&r1=1784126&r2=1784127&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
Thu Feb 23 13:26:36 2017
@@ -130,9 +130,7 @@ public final class HttpHost implements N
      * @since 4.4
      */
     public static HttpHost create(final String s) throws URISyntaxException {
-        if (s == null) {
-            return null;
-        }
+        Args.notEmpty(s, "HTTP Host");
         String text = s;
         String scheme = null;
         final int schemeIdx = text.indexOf("://");

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java?rev=1784127&r1=1784126&r2=1784127&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
Thu Feb 23 13:26:36 2017
@@ -84,6 +84,9 @@ public class Args {
         if (argument == null) {
             throw new IllegalArgumentException(name + " may not be null");
         }
+        if (argument.length() == 0) {
+            throw new IllegalArgumentException(name + " may not be empty");
+        }
         if (TextUtils.containsBlanks(argument)) {
             throw new IllegalArgumentException(name + " may not contain blanks");
         }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java?rev=1784127&r1=1784126&r2=1784127&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
Thu Feb 23 13:26:36 2017
@@ -215,6 +215,11 @@ public class TestHttpHost {
             Assert.fail("URISyntaxException expected");
         } catch (final URISyntaxException expected) {
         }
+        try {
+            HttpHost.create("");
+            Assert.fail("IllegalArgumentException expected");
+        } catch (final IllegalArgumentException expected) {
+        }
     }
 
 }



Mime
View raw message