Skip to content

Commit 3ae7ae2

Browse files
committed
[java] Reverting changes made regarding setting proxy via system properties
@joerg1985's comment on the change was correct. Java defaults to using the DefaultProxySelector which uses the system properties. Apologies, I headed down the wrong path earlier. Fixing it as part of this change.
1 parent b65ad22 commit 3ae7ae2

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,34 +124,28 @@ protected PasswordAuthentication getPasswordAuthentication() {
124124
builder = builder.authenticator(authenticator);
125125
}
126126

127-
String proxyHost = System.getProperty("http.proxyHost");
128-
String proxyPort = System.getProperty("http.proxyPort");
129-
130-
Proxy proxy =
131-
(proxyHost != null && proxyPort != null)
132-
? new Proxy(
133-
Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)))
134-
: config.proxy();
135-
136-
ProxySelector proxySelector =
137-
new ProxySelector() {
138-
@Override
139-
public List<Proxy> select(URI uri) {
140-
if (proxy == null) {
127+
Proxy proxy = config.proxy();
128+
if (proxy != null) {
129+
ProxySelector proxySelector =
130+
new ProxySelector() {
131+
@Override
132+
public List<Proxy> select(URI uri) {
133+
if (proxy == null) {
134+
return List.of();
135+
}
136+
if (uri.getScheme().toLowerCase().startsWith("http")) {
137+
return List.of(proxy);
138+
}
141139
return List.of();
142140
}
143-
if (uri.getScheme().toLowerCase().startsWith("http")) {
144-
return List.of(proxy);
145-
}
146-
return List.of();
147-
}
148141

149-
@Override
150-
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
151-
// Do nothing
152-
}
153-
};
154-
builder = builder.proxy(proxySelector);
142+
@Override
143+
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
144+
// Do nothing
145+
}
146+
};
147+
builder = builder.proxy(proxySelector);
148+
}
155149

156150
SSLContext sslContext = config.sslContext();
157151
if (sslContext != null) {

0 commit comments

Comments
 (0)