Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 96801200C73 for ; Wed, 26 Apr 2017 01:22:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 95054160BB6; Tue, 25 Apr 2017 23:22:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B61DE160BB3 for ; Wed, 26 Apr 2017 01:22:29 +0200 (CEST) Received: (qmail 34959 invoked by uid 500); 25 Apr 2017 23:22:29 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 34950 invoked by uid 99); 25 Apr 2017 23:22:28 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Apr 2017 23:22:28 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 552103A0F9A for ; Tue, 25 Apr 2017 23:22:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1792683 - /httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java Date: Tue, 25 Apr 2017 23:22:27 -0000 To: commits@hc.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170425232228.552103A0F9A@svn01-us-west.apache.org> archived-at: Tue, 25 Apr 2017 23:22:30 -0000 Author: ggregory Date: Tue Apr 25 23:22:27 2017 New Revision: 1792683 URL: http://svn.apache.org/viewvc?rev=1792683&view=rev Log: HTTPCORE-458: Validate port values. Add checks and Javadoc. Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.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=1792683&r1=1792682&r2=1792683&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 Tue Apr 25 23:22:27 2017 @@ -69,12 +69,17 @@ public final class HttpHost implements N private final InetAddress address; + /** + * @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 HttpHost(final String hostname, final int port, final String scheme, final boolean internal) { super(); this.hostname = hostname; this.lcHostname = hostname; this.schemeName = scheme; - this.port = port; + this.port = Ports.check(port); this.address = null; } @@ -87,6 +92,10 @@ public final class HttpHost implements N * @param scheme the name of the scheme. * {@code null} indicates the * {@link #DEFAULT_SCHEME_NAME default scheme} + * + * @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 HttpHost(final String hostname, final int port, final String scheme) { super(); @@ -97,7 +106,7 @@ public final class HttpHost implements N } else { this.schemeName = DEFAULT_SCHEME_NAME; } - this.port = port; + this.port = Ports.check(port); this.address = null; } @@ -107,6 +116,10 @@ public final class HttpHost implements N * @param hostname the hostname (IP or DNS name) * @param port the port number. * {@code -1} indicates the scheme default 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 HttpHost(final String hostname, final int port) { this(hostname, port, null); @@ -119,6 +132,10 @@ public final class HttpHost implements N * @param scheme the name of the scheme. * {@code null} indicates the * {@link #DEFAULT_SCHEME_NAME default scheme} + * + * @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 HttpHost(final String hostname, final String scheme) { this(hostname, -1, scheme); @@ -164,6 +181,10 @@ public final class HttpHost implements N * Creates {@code HttpHost} instance with the default scheme and port and the given hostname. * * @param hostname the hostname (IP or DNS name) + * + * @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 HttpHost(final String hostname) { this(hostname, -1, null); @@ -182,6 +203,7 @@ public final class HttpHost implements N * @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. + * * @since 4.3 */ public HttpHost(final InetAddress address, final int port, final String scheme) { @@ -202,6 +224,7 @@ public final class HttpHost implements N * @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. + * * @since 4.4 */ public HttpHost(final InetAddress address, final String hostname, final int port, final String scheme) { @@ -228,6 +251,7 @@ public final class HttpHost implements N * @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. + * * @since 4.3 */ public HttpHost(final InetAddress address, final int port) { @@ -243,6 +267,7 @@ public final class HttpHost implements N * @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. + * * @since 4.3 */ public HttpHost(final InetAddress address) { @@ -250,6 +275,10 @@ public final class HttpHost implements N } /** + * @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. + * * @since 5.0 */ public HttpHost(final NamedEndpoint namedEndpoint, final String scheme) { @@ -257,6 +286,10 @@ public final class HttpHost implements N } /** + * @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. + * * @since 5.0 */ public HttpHost(final URIAuthority authority) {