5757import java .sql .SQLException ;
5858import java .sql .Statement ;
5959import java .util .ArrayList ;
60+ import java .util .HashMap ;
6061import java .util .List ;
62+ import java .util .Map ;
6163import org .junit .jupiter .api .AfterAll ;
6264import org .junit .jupiter .api .BeforeAll ;
6365import 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