Skip to content

Commit 0757d83

Browse files
committed
Minor clean up
1 parent 61cd375 commit 0757d83

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,13 +800,12 @@ public Builder setValidateResponseHeaders(boolean validateResponseHeaders) {
800800
}
801801

802802
public Builder setProxyServer(ProxyServer proxyServer) {
803-
this.proxyServerSelector = ProxyUtils.createProxyServerSelector(proxyServer);
803+
this.proxyServerSelector = uri -> proxyServer;
804804
return this;
805805
}
806806

807807
public Builder setProxyServer(ProxyServer.Builder proxyServerBuilder) {
808-
this.proxyServerSelector = ProxyUtils.createProxyServerSelector(proxyServerBuilder.build());
809-
return this;
808+
return setProxyServer(proxyServerBuilder.build());
810809
}
811810

812811
public Builder setUseProxySelector(boolean useProxySelector) {

client/src/main/java/org/asynchttpclient/proxy/ProxyServerSelector.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,5 @@ public interface ProxyServerSelector {
1818
/**
1919
* A selector that always selects no proxy.
2020
*/
21-
ProxyServerSelector NO_PROXY_SELECTOR = new ProxyServerSelector() {
22-
@Override
23-
public ProxyServer select(Uri uri) {
24-
return null;
25-
}
26-
};
21+
ProxyServerSelector NO_PROXY_SELECTOR = uri -> null;
2722
}

client/src/main/java/org/asynchttpclient/util/ProxyUtils.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*/
4141
public final class ProxyUtils {
4242

43-
private final static Logger log = LoggerFactory.getLogger(ProxyUtils.class);
43+
private final static Logger logger = LoggerFactory.getLogger(ProxyUtils.class);
4444

4545
/**
4646
* The host to use as proxy.
@@ -123,7 +123,8 @@ public static ProxyServerSelector createProxyServerSelector(Properties propertie
123123
proxyServer.setNonProxyHosts(new ArrayList<>(Arrays.asList(nonProxyHosts.split("\\|"))));
124124
}
125125

126-
return createProxyServerSelector(proxyServer.build());
126+
ProxyServer proxy = proxyServer.build();
127+
return uri -> proxy;
127128
}
128129

129130
return ProxyServerSelector.NO_PROXY_SELECTOR;
@@ -157,7 +158,7 @@ public ProxyServer select(Uri uri) {
157158
switch (proxy.type()) {
158159
case HTTP:
159160
if (!(proxy.address() instanceof InetSocketAddress)) {
160-
log.warn("Don't know how to connect to address " + proxy.address());
161+
logger.warn("Don't know how to connect to address " + proxy.address());
161162
return null;
162163
} else {
163164
InetSocketAddress address = (InetSocketAddress) proxy.address();
@@ -166,31 +167,17 @@ public ProxyServer select(Uri uri) {
166167
case DIRECT:
167168
return null;
168169
default:
169-
log.warn("ProxySelector returned proxy type that we don't know how to use: " + proxy.type());
170+
logger.warn("ProxySelector returned proxy type that we don't know how to use: " + proxy.type());
170171
break;
171172
}
172173
}
173174
}
174175
return null;
175176
} catch (URISyntaxException e) {
176-
log.warn(uri + " couldn't be turned into a java.net.URI", e);
177+
logger.warn(uri + " couldn't be turned into a java.net.URI", e);
177178
return null;
178179
}
179180
}
180181
};
181182
}
182-
183-
/**
184-
* Create a proxy server selector that always selects a single proxy server.
185-
*
186-
* @param proxyServer The proxy server to select.
187-
* @return The proxy server selector.
188-
*/
189-
public static ProxyServerSelector createProxyServerSelector(final ProxyServer proxyServer) {
190-
return new ProxyServerSelector() {
191-
public ProxyServer select(Uri uri) {
192-
return proxyServer;
193-
}
194-
};
195-
}
196183
}

0 commit comments

Comments
 (0)