--- old/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java 2017-01-31 11:35:54.000000000 +0000 +++ new/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java 2017-01-31 11:35:53.000000000 +0000 @@ -30,16 +30,19 @@ import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.StringJoiner; import java.util.regex.Pattern; +import java.util.stream.Stream; import sun.net.NetProperties; import sun.net.SocksProxy; import static java.util.regex.Pattern.quote; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; /** * Supports proxy settings using system properties This proxy selector @@ -318,9 +321,16 @@ return null; }}); - // If no specific proxy was found we return our standard list containing + + if (proxyArray != null) { + // Remove duplicate entries, while preserving order. + return Stream.of(proxyArray).distinct().collect( + collectingAndThen(toList(), Collections::unmodifiableList)); + } + + // If no specific proxy was found, return a standard list containing // only one NO_PROXY entry. - return proxyArray == null ? NO_PROXY_LIST : List.of(proxyArray); + return NO_PROXY_LIST; } public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {