Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset ProxySelector when exit plugin #2217

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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