Skip to content

Commit

Permalink
#2209 reset ProxySelector when exit plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ivywei0125 committed Feb 2, 2023
1 parent 4d7de5f commit 2e34ecd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ public void execute() throws MojoExecutionException {
} catch (InterruptedException e) {
// swallow this exception
}
ProxyManager.getInstance().resetProxy();
ApacheSenderFactory.INSTANCE.create().close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ProxyManager {
// isSystemProxyUnset shows whether user specify the proxy through -Djava.net.useSystemProxies
// see: https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
private static final boolean isSystemProxyUnset = StringUtils.isBlank(System.getProperty(PROPERTY_USE_SYSTEM_PROXY));
private final ProxySelector defaultProxySelector = ProxySelector.getDefault();

public boolean isProxyEnabled() {
return StringUtils.isNotBlank(Azure.az().config().getProxySource());
Expand Down Expand Up @@ -95,6 +96,10 @@ public PasswordAuthentication getPasswordAuthentication() {
}
}

public void resetProxy() {
ProxySelector.setDefault(this.defaultProxySelector);
}

private ProxyInfo getSystemProxy() {
// we need to init at the program start before any internet access
if (isSystemProxyUnset) {
Expand Down

0 comments on commit 2e34ecd

Please sign in to comment.