You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2017/04/25 23:26:08 UTC
svn commit: r1792684 -
/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
Author: ggregory
Date: Tue Apr 25 23:26:07 2017
New Revision: 1792684
URL: http://svn.apache.org/viewvc?rev=1792684&view=rev
Log:
HTTPCORE-458: Validate port values. Add checks and Javadoc.
Modified:
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java?rev=1792684&r1=1792683&r2=1792684&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java Tue Apr 25 23:26:07 2017
@@ -49,13 +49,23 @@ public final class URIAuthority implemen
private final String hostname;
private final int port;
+ /**
+ * @throws IllegalArgumentException
+ * If the port parameter is outside the specified range of valid port values, which is between 0 and
+ * 65535, inclusive. {@code -1} indicates the scheme default port.
+ */
private URIAuthority(final String userInfo, final String hostname, final int port, final boolean internal) {
super();
this.userInfo = userInfo;
this.hostname = hostname;
- this.port = port;
+ this.port = Ports.check(port);
}
+ /**
+ * @throws IllegalArgumentException
+ * If the port parameter is outside the specified range of valid port values, which is between 0 and
+ * 65535, inclusive. {@code -1} indicates the scheme default port.
+ */
public URIAuthority(final String userInfo, final String hostname, final int port) {
super();
Args.containsNoBlanks(hostname, "Host name");
@@ -64,7 +74,7 @@ public final class URIAuthority implemen
}
this.userInfo = userInfo;
this.hostname = hostname.toLowerCase(Locale.ROOT);
- this.port = port;
+ this.port = Ports.check(port);
}
public URIAuthority(final String hostname, final int port) {