From 6fcaa322d90f06ba79a8fc30ebe314aa9ea8e959 Mon Sep 17 00:00:00 2001 From: Daniel Jelinski Date: Thu, 13 Jan 2022 14:41:55 +0000 Subject: [PATCH] 8262442: (windows) Use all proxy configuration sources when java.net.useSystemProxies=true Reviewed-by: dfuchs --- .../native/libnet/DefaultProxySelector.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/java.base/windows/native/libnet/DefaultProxySelector.c b/src/java.base/windows/native/libnet/DefaultProxySelector.c index 74efd4ab91e3a..d9107e738b373 100644 --- a/src/java.base/windows/native/libnet/DefaultProxySelector.c +++ b/src/java.base/windows/native/libnet/DefaultProxySelector.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -230,16 +230,12 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env, auto_proxy_options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT; auto_proxy_options.fAutoLogonIfChallenged = TRUE; use_auto_proxy = TRUE; - } else if (ie_proxy_config.lpszAutoConfigUrl != NULL) { + } + if (ie_proxy_config.lpszAutoConfigUrl != NULL) { /* Windows uses PAC file */ auto_proxy_options.lpszAutoConfigUrl = ie_proxy_config.lpszAutoConfigUrl; - auto_proxy_options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; + auto_proxy_options.dwFlags |= WINHTTP_AUTOPROXY_CONFIG_URL; use_auto_proxy = TRUE; - } else if (ie_proxy_config.lpszProxy != NULL) { - /* Windows uses manually entered proxy. */ - use_auto_proxy = FALSE; - win_bypass_proxy = ie_proxy_config.lpszProxyBypass; - win_proxy = ie_proxy_config.lpszProxy; } if (use_auto_proxy) { @@ -254,6 +250,12 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env, } } + if (!use_auto_proxy && ie_proxy_config.lpszProxy != NULL) { + /* Windows uses manually entered proxy. */ + win_bypass_proxy = ie_proxy_config.lpszProxyBypass; + win_proxy = ie_proxy_config.lpszProxy; + } + /* Check the bypass entry. */ if (NULL != win_bypass_proxy) { /*