From 855da0bebdc28c26f217aa124b765e36676e23a1 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Wed, 25 Oct 2023 00:01:37 +1000 Subject: [PATCH] Fix list of non proxy hosts (#232) --- .../io/jenkins/plugins/azuresdk/HttpClientRetriever.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/azuresdk/HttpClientRetriever.java b/src/main/java/io/jenkins/plugins/azuresdk/HttpClientRetriever.java index 844b7dc..2043c40 100644 --- a/src/main/java/io/jenkins/plugins/azuresdk/HttpClientRetriever.java +++ b/src/main/java/io/jenkins/plugins/azuresdk/HttpClientRetriever.java @@ -10,6 +10,9 @@ import jenkins.util.JenkinsJVM; import java.net.InetSocketAddress; +import java.util.Arrays; +import java.util.stream.Collectors; + import jenkins.util.SystemProperties; public class HttpClientRetriever { @@ -40,7 +43,11 @@ public static HttpClient get(ProxyConfiguration proxy) { } String noProxyHost = Util.fixEmpty(proxy.getNoProxyHost()); if (noProxyHost != null) { - proxyOptions.setNonProxyHosts(noProxyHost); + // com.azure.core.http.ProxyOptions accepts a '|' delimited String + // https://learn.microsoft.com/en-us/java/api/com.azure.core.http.proxyoptions?view=azure-java-stable#com-azure-core-http-proxyoptions-setnonproxyhosts(java-lang-string) + proxyOptions.setNonProxyHosts(Arrays.stream(noProxyHost.split("[ \t\n,|]+")) + .filter(s -> !s.isEmpty()) + .collect(Collectors.joining("|"))); } }