Skip to content

Commit ce8533d

Browse files
committed
parquet-hadoop tests to work behind a web proxy
1 parent 4c8f4d4 commit ce8533d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

parquet-hadoop/src/test/java/org/apache/parquet/hadoop/InterOpTester.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
package org.apache.parquet.hadoop;
2121

2222
import java.io.IOException;
23+
import java.net.InetSocketAddress;
24+
import java.net.Proxy;
2325
import okhttp3.OkHttpClient;
2426
import okhttp3.Request;
2527
import okhttp3.Response;
@@ -34,7 +36,24 @@ public class InterOpTester {
3436
private static final String PARQUET_TESTING_REPO = "https://github.com/apache/parquet-testing/raw/";
3537
private static final String PARQUET_TESTING_PATH = "target/parquet-testing/";
3638
private static final Logger LOG = LoggerFactory.getLogger(InterOpTester.class);
37-
private OkHttpClient httpClient = new OkHttpClient();
39+
// since PARQUET_TESTING_REPO might be beyond a web proxy ...
40+
private static OkHttpClient createOkHttpClientOptProxy() {
41+
String proxyHost = System.getProperty("https.proxyHost");
42+
String proxyPort = System.getProperty("https.proxyPort");
43+
OkHttpClient client = null;
44+
if (proxyHost != null || proxyPort != null) {
45+
try {
46+
int port = Integer.valueOf(proxyPort);
47+
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, port));
48+
client = new OkHttpClient.Builder().proxy(proxy).build();
49+
} catch (NumberFormatException e) {
50+
}
51+
}
52+
if (client == null) client = new OkHttpClient();
53+
return client;
54+
}
55+
56+
private OkHttpClient httpClient = createOkHttpClientOptProxy();
3857

3958
public Path GetInterOpFile(String fileName, String changeset) throws IOException {
4059
return GetInterOpFile(fileName, changeset, "data");

0 commit comments

Comments
 (0)