40
40
*/
41
41
public final class ProxyUtils {
42
42
43
- private final static Logger log = LoggerFactory .getLogger (ProxyUtils .class );
43
+ private final static Logger logger = LoggerFactory .getLogger (ProxyUtils .class );
44
44
45
45
/**
46
46
* The host to use as proxy.
@@ -123,7 +123,8 @@ public static ProxyServerSelector createProxyServerSelector(Properties propertie
123
123
proxyServer .setNonProxyHosts (new ArrayList <>(Arrays .asList (nonProxyHosts .split ("\\ |" ))));
124
124
}
125
125
126
- return createProxyServerSelector (proxyServer .build ());
126
+ ProxyServer proxy = proxyServer .build ();
127
+ return uri -> proxy ;
127
128
}
128
129
129
130
return ProxyServerSelector .NO_PROXY_SELECTOR ;
@@ -157,7 +158,7 @@ public ProxyServer select(Uri uri) {
157
158
switch (proxy .type ()) {
158
159
case HTTP :
159
160
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 ());
161
162
return null ;
162
163
} else {
163
164
InetSocketAddress address = (InetSocketAddress ) proxy .address ();
@@ -166,31 +167,17 @@ public ProxyServer select(Uri uri) {
166
167
case DIRECT :
167
168
return null ;
168
169
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 ());
170
171
break ;
171
172
}
172
173
}
173
174
}
174
175
return null ;
175
176
} 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 );
177
178
return null ;
178
179
}
179
180
}
180
181
};
181
182
}
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
- }
196
183
}
0 commit comments