@@ -101,11 +101,11 @@ public static class Builder extends ClientConfig.AbstractBuilder<HttpClientConfi
101
101
private Map <HttpRoute , Integer > maxTotalConnectionPerRoute = new HashMap <HttpRoute , Integer >();
102
102
private CredentialsProvider credentialsProvider ;
103
103
private LayeredConnectionSocketFactory sslSocketFactory ;
104
- private ConnectionSocketFactory plainSocketFactory = PlainConnectionSocketFactory . getSocketFactory () ;
105
- private HttpRoutePlanner httpRoutePlanner = new SystemDefaultRoutePlanner ( ProxySelector . getDefault ()) ;
104
+ private ConnectionSocketFactory plainSocketFactory ;
105
+ private HttpRoutePlanner httpRoutePlanner ;
106
106
private AuthenticationStrategy proxyAuthenticationStrategy ;
107
- private SchemeIOSessionStrategy httpIOSessionStrategy = NoopIOSessionStrategy . INSTANCE ;
108
- private SchemeIOSessionStrategy httpsIOSessionStrategy = SSLIOSessionStrategy . getSystemDefaultStrategy () ;
107
+ private SchemeIOSessionStrategy httpIOSessionStrategy ;
108
+ private SchemeIOSessionStrategy httpsIOSessionStrategy ;
109
109
110
110
public Builder (HttpClientConfig httpClientConfig ) {
111
111
super (httpClientConfig );
@@ -242,10 +242,22 @@ public Builder proxy(HttpHost proxy, AuthenticationStrategy proxyAuthenticationS
242
242
}
243
243
244
244
public HttpClientConfig build () {
245
+ // Lazily initialize if necessary, as the call can be expensive when done eagerly.
245
246
if (this .sslSocketFactory == null ) {
246
- // Lazily initialize if necessary, as the call can be expensive when done eagerly.
247
247
this .sslSocketFactory = SSLConnectionSocketFactory .getSocketFactory ();
248
248
}
249
+ if (this .plainSocketFactory == null ) {
250
+ this .plainSocketFactory = PlainConnectionSocketFactory .getSocketFactory ();
251
+ }
252
+ if (this .httpRoutePlanner == null ) {
253
+ this .httpRoutePlanner = new SystemDefaultRoutePlanner (ProxySelector .getDefault ());
254
+ }
255
+ if (this .httpIOSessionStrategy == null ) {
256
+ this .httpIOSessionStrategy = NoopIOSessionStrategy .INSTANCE ;
257
+ }
258
+ if (this .httpsIOSessionStrategy == null ) {
259
+ this .httpsIOSessionStrategy = SSLIOSessionStrategy .getSystemDefaultStrategy ();
260
+ }
249
261
return new HttpClientConfig (this );
250
262
}
251
263
0 commit comments