Skip to content

Commit

Permalink
CLOUD-1520: Don't use proxy for all communications at all
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
jwendell authored and knrc committed Jun 6, 2017
1 parent 46b7642 commit 1d99588
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.security.cert.CertificateException;
Expand Down Expand Up @@ -79,7 +80,7 @@ public URLConnection openConnection(String url, Map<String, String> headers, int
"%s opening connection: url [%s], headers [%s], connectTimeout [%s], readTimeout [%s]", getClass()
.getSimpleName(), url, headers, connectTimeout, readTimeout));
}
URLConnection connection = new URL(url).openConnection();
URLConnection connection = new URL(url).openConnection(Proxy.NO_PROXY);
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.addRequestProperty(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -274,7 +275,7 @@ public void run() {
}
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) new URL(url).openConnection();
connection = (HttpURLConnection) new URL(url).openConnection(Proxy.NO_PROXY);
connection.addRequestProperty(Server.CLUSTER_NAME, clusterName);
if (_connectTimeout < 0 || _readTimeout < 0) {
throw new IllegalArgumentException(String.format(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openshift.ping.common.stream;

import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
Expand All @@ -14,7 +15,7 @@ public URLConnection openConnection(String url, Map<String, String> headers, int
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, String.format("%s opening connection: url [%s], headers [%s], connectTimeout [%s], readTimeout [%s]", getClass().getSimpleName(), url, headers, connectTimeout, readTimeout));
}
URLConnection connection = new URL(url).openConnection();
URLConnection connection = new URL(url).openConnection(Proxy.NO_PROXY);
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.addRequestProperty(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void testResponse() throws Exception {
Message msg = new Message(null).setFlag(Message.Flag.DONT_BUNDLE)
.putHeader(pinger.getId(), hdr).setBuffer(streamableToBuffer(data));
URL url = new URL("http://localhost:8888");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
HttpURLConnection conn = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
conn.addRequestProperty(Server.CLUSTER_NAME, TestBase.CLUSTER_NAME);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
Expand Down

0 comments on commit 1d99588

Please sign in to comment.