Skip to content

Commit 2a7210a

Browse files
committed
pr feedback
1 parent 560f11c commit 2a7210a

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
import java.sql.SQLException;
5858
import java.sql.Statement;
5959
import java.util.ArrayList;
60+
import java.util.HashMap;
6061
import java.util.List;
62+
import java.util.Map;
6163
import org.junit.jupiter.api.AfterAll;
6264
import org.junit.jupiter.api.BeforeAll;
6365
import org.junit.jupiter.api.Test;
@@ -66,11 +68,18 @@ public class ITOpenTelemetryTest extends ITBase {
6668

6769
private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId();
6870
private static final String CONNECTION_URL = connectionUrl;
71+
private static final String[] PROXY_SYS_PROPS = {
72+
"https.proxyHost", "https.proxyPort", "http.proxyHost", "http.proxyPort"
73+
};
74+
private static final Map<String, String> originalSystemProperties = new HashMap<>();
6975

7076
@BeforeAll
7177
public static void setUpProxyProperties() {
7278
DataSource ds = DataSource.fromUrl(CONNECTION_URL);
7379
if (ds.getProxyHost() != null && ds.getProxyPort() != null) {
80+
for (String prop : PROXY_SYS_PROPS) {
81+
originalSystemProperties.put(prop, System.getProperty(prop));
82+
}
7483
System.setProperty("https.proxyHost", ds.getProxyHost());
7584
System.setProperty("https.proxyPort", ds.getProxyPort());
7685
System.setProperty("http.proxyHost", ds.getProxyHost());
@@ -80,10 +89,13 @@ public static void setUpProxyProperties() {
8089

8190
@AfterAll
8291
public static void tearDownProxyProperties() {
83-
System.clearProperty("https.proxyHost");
84-
System.clearProperty("https.proxyPort");
85-
System.clearProperty("http.proxyHost");
86-
System.clearProperty("http.proxyPort");
92+
for (Map.Entry<String, String> entry : originalSystemProperties.entrySet()) {
93+
if (entry.getValue() != null) {
94+
System.setProperty(entry.getKey(), entry.getValue());
95+
} else {
96+
System.clearProperty(entry.getKey());
97+
}
98+
}
8799
}
88100

89101
@Test

0 commit comments

Comments
 (0)