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 116BD200B6C for ; Sun, 28 Aug 2016 15:02:42 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 031ED160AB4; Sun, 28 Aug 2016 13:02:42 +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 488BE160AAF for ; Sun, 28 Aug 2016 15:02:41 +0200 (CEST) Received: (qmail 15779 invoked by uid 500); 28 Aug 2016 13:02:40 -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 15770 invoked by uid 99); 28 Aug 2016 13:02:40 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Aug 2016 13:02:40 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id BF9201A009A for ; Sun, 28 Aug 2016 13:02:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.426 X-Spam-Level: X-Spam-Status: No, score=-0.426 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id TxM2IE39suEO for ; Sun, 28 Aug 2016 13:02:38 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTP id 3ECED5F23C for ; Sun, 28 Aug 2016 13:02:38 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1E17AE00B8 for ; Sun, 28 Aug 2016 13:02:37 +0000 (UTC) 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 27D9F3A0248 for ; Sun, 28 Aug 2016 13:02:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1758106 - /httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java Date: Sun, 28 Aug 2016 13:02:35 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160828130236.27D9F3A0248@svn01-us-west.apache.org> archived-at: Sun, 28 Aug 2016 13:02:42 -0000 Author: olegk Date: Sun Aug 28 13:02:35 2016 New Revision: 1758106 URL: http://svn.apache.org/viewvc?rev=1758106&view=rev Log: Support changing system default ProxySelector Contributed by Robin Stevens The `ProxySelectorRoutePlanner` class which got deprecated in favor of the `SystemDefaultRoutePlanner` could deal with: - `null` as default `ProxySelector` - a change in the default `ProxySelector` This change ports that behavior to the `SystemDefaultRoutePlanner`. Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java?rev=1758106&r1=1758105&r2=1758106&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java (original) +++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/SystemDefaultRoutePlanner.java Sun Aug 28 13:02:35 2016 @@ -54,13 +54,19 @@ public class SystemDefaultRoutePlanner e private final ProxySelector proxySelector; + /** + * @param proxySelector the proxy selector, or {@code null} for the system default + */ public SystemDefaultRoutePlanner( final SchemePortResolver schemePortResolver, final ProxySelector proxySelector) { super(schemePortResolver); - this.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault(); + this.proxySelector = proxySelector; } + /** + * @param proxySelector the proxy selector, or {@code null} for the system default + */ public SystemDefaultRoutePlanner(final ProxySelector proxySelector) { this(null, proxySelector); } @@ -76,7 +82,15 @@ public class SystemDefaultRoutePlanner e } catch (final URISyntaxException ex) { throw new HttpException("Cannot convert host to URI: " + target, ex); } - final List proxies = this.proxySelector.select(targetURI); + ProxySelector proxySelectorInstance = this.proxySelector; + if (proxySelectorInstance == null) { + proxySelectorInstance = ProxySelector.getDefault(); + } + if (proxySelectorInstance == null) { + //The proxy selector can be "unset", so we must be able to deal with a null selector + return null; + } + final List proxies = proxySelectorInstance.select(targetURI); final Proxy p = chooseProxy(proxies); HttpHost result = null; if (p.type() == Proxy.Type.HTTP) {