Skip to content

Commit 0f8cc97

Browse files
committed
fix java 11
1 parent 19959c3 commit 0f8cc97

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/config/EnvironmentProxyConfigurer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public static void apply() {
7575
if (noProxy != null && System.getProperty("http.nonProxyHosts") == null) {
7676
final String list = noProxy.replace(',', '|');
7777
setProperty("http.nonProxyHosts", list);
78-
setProperty("https.nonProxyHosts", list);
78+
/* only write HTTPS when it is still unset */
79+
if (System.getProperty("https.nonProxyHosts") == null) { // ← FIX
80+
setProperty("https.nonProxyHosts", list);
81+
}
7982
}
8083
}
8184

httpclient5/src/test/java/org/apache/hc/client5/http/config/EnvironmentProxyConfigurerTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,20 @@ void does_not_overwrite_already_set_properties() throws Exception {
9999
void translates_no_proxy_to_pipe_delimited_hosts() throws Exception {
100100
backup("http.nonProxyHosts", "https.nonProxyHosts");
101101

102+
// ensure both props are null before we invoke the bridge
103+
System.clearProperty("http.nonProxyHosts");
104+
System.clearProperty("https.nonProxyHosts");
105+
102106
withEnvironmentVariable("NO_PROXY", "localhost,127.0.0.1")
103107
.execute(() -> {
104-
final String beforeHttp = System.getProperty("http.nonProxyHosts");
105-
final String beforeHttps = System.getProperty("https.nonProxyHosts");
106-
107108
EnvironmentProxyConfigurer.apply();
108-
109-
final String expected = "localhost|127.0.0.1";
110-
assertEquals(
111-
beforeHttp != null ? beforeHttp : expected,
109+
assertEquals("localhost|127.0.0.1",
112110
System.getProperty("http.nonProxyHosts"));
113-
assertEquals(
114-
beforeHttps != null ? beforeHttps : expected,
111+
assertEquals("localhost|127.0.0.1",
115112
System.getProperty("https.nonProxyHosts"));
116113
});
117114
}
118115

119-
120116
@Test
121117
void noop_when_no_relevant_env_vars() {
122118
backup("http.proxyHost");

0 commit comments

Comments
 (0)