Skip to content

Commit

Permalink
Improved cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astachowski committed Oct 25, 2024
1 parent 665ca93 commit e4743d8
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ public static void setUp() throws Exception {
originalNonProxyHosts = System.getProperty("https.nonProxyHosts");
}

private static void restoreProperty(String key, String value) {
if (value != null) {
System.setProperty(key, value);
} else {
System.clearProperty(key);
}
}

@AfterClass
public static void tearDown() throws Exception {
if (originalProxyHost != null) {
System.setProperty("https.proxyHost", originalProxyHost);
}
if (originalProxyPort != null) {
System.setProperty("https.proxyPort", originalProxyPort);
}
if (originalNonProxyHosts != null) {
System.setProperty("https.nonProxyHosts", originalNonProxyHosts);
}
restoreProperty("https.proxyHost", originalProxyHost);
restoreProperty("https.proxyPort", originalProxyPort);
restoreProperty("https.nonProxyHosts", originalNonProxyHosts);
}
/**
* Tests that the chunk downloader uses the maxHttpRetries and doesn't enter and infinite loop of
Expand Down

0 comments on commit e4743d8

Please sign in to comment.