Skip to content

Commit 1d99588

Browse files
jwendellknrc
authored andcommitted
CLOUD-1520: Don't use proxy for all communications at all
Communications intra-pods don't need to be proxied. In fact they must not. This patch prevents traffic being routed to a proxy in case a java property like "http.proxyHost" is set in the environment. As a side effect of this change, clustering will not be affected by env variables like "https_proxy".
1 parent 46b7642 commit 1d99588

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

activemq/src/main/java/org/openshift/activemq/discoveryagent/kube/InsecureStreamProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.net.HttpURLConnection;
22+
import java.net.Proxy;
2223
import java.net.URL;
2324
import java.net.URLConnection;
2425
import java.security.cert.CertificateException;
@@ -79,7 +80,7 @@ public URLConnection openConnection(String url, Map<String, String> headers, int
7980
"%s opening connection: url [%s], headers [%s], connectTimeout [%s], readTimeout [%s]", getClass()
8081
.getSimpleName(), url, headers, connectTimeout, readTimeout));
8182
}
82-
URLConnection connection = new URL(url).openConnection();
83+
URLConnection connection = new URL(url).openConnection(Proxy.NO_PROXY);
8384
if (headers != null) {
8485
for (Map.Entry<String, String> entry : headers.entrySet()) {
8586
connection.addRequestProperty(entry.getKey(), entry.getValue());

common/src/main/java/org/openshift/ping/common/OpenshiftPing.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.lang.reflect.Method;
2626
import java.net.HttpURLConnection;
2727
import java.net.InetSocketAddress;
28+
import java.net.Proxy;
2829
import java.net.URL;
2930
import java.util.Collections;
3031
import java.util.List;
@@ -274,7 +275,7 @@ public void run() {
274275
}
275276
HttpURLConnection connection = null;
276277
try {
277-
connection = (HttpURLConnection) new URL(url).openConnection();
278+
connection = (HttpURLConnection) new URL(url).openConnection(Proxy.NO_PROXY);
278279
connection.addRequestProperty(Server.CLUSTER_NAME, clusterName);
279280
if (_connectTimeout < 0 || _readTimeout < 0) {
280281
throw new IllegalArgumentException(String.format(

common/src/main/java/org/openshift/ping/common/stream/BaseStreamProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.openshift.ping.common.stream;
22

33
import java.io.IOException;
4+
import java.net.Proxy;
45
import java.net.URL;
56
import java.net.URLConnection;
67
import java.util.Map;
@@ -14,7 +15,7 @@ public URLConnection openConnection(String url, Map<String, String> headers, int
1415
if (log.isLoggable(Level.FINE)) {
1516
log.log(Level.FINE, String.format("%s opening connection: url [%s], headers [%s], connectTimeout [%s], readTimeout [%s]", getClass().getSimpleName(), url, headers, connectTimeout, readTimeout));
1617
}
17-
URLConnection connection = new URL(url).openConnection();
18+
URLConnection connection = new URL(url).openConnection(Proxy.NO_PROXY);
1819
if (headers != null) {
1920
for (Map.Entry<String, String> entry : headers.entrySet()) {
2021
connection.addRequestProperty(entry.getKey(), entry.getValue());

kube/src/test/java/org/openshift/ping/kube/test/ServerTestBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.lang.reflect.Constructor;
2222
import java.lang.reflect.Method;
2323
import java.net.HttpURLConnection;
24+
import java.net.Proxy;
2425
import java.net.URL;
2526
import java.util.Arrays;
2627
import java.util.Collection;
@@ -81,7 +82,7 @@ public void testResponse() throws Exception {
8182
Message msg = new Message(null).setFlag(Message.Flag.DONT_BUNDLE)
8283
.putHeader(pinger.getId(), hdr).setBuffer(streamableToBuffer(data));
8384
URL url = new URL("http://localhost:8888");
84-
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
85+
HttpURLConnection conn = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
8586
conn.addRequestProperty(Server.CLUSTER_NAME, TestBase.CLUSTER_NAME);
8687
conn.setDoOutput(true);
8788
conn.setRequestMethod("POST");

0 commit comments

Comments
 (0)