Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Lazily instantiate SSLConnectionSocketFactory to avoid expensive call #252

Merged
merged 1 commit into from
Nov 4, 2015
Merged
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 @@ -100,7 +100,7 @@ public static class Builder extends ClientConfig.AbstractBuilder<HttpClientConfi
private Integer defaultMaxTotalConnectionPerRoute;
private Map<HttpRoute, Integer> maxTotalConnectionPerRoute = new HashMap<HttpRoute, Integer>();
private CredentialsProvider credentialsProvider;
private LayeredConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactory.getSocketFactory();
private LayeredConnectionSocketFactory sslSocketFactory;
private ConnectionSocketFactory plainSocketFactory = PlainConnectionSocketFactory.getSocketFactory();
private HttpRoutePlanner httpRoutePlanner = new SystemDefaultRoutePlanner(ProxySelector.getDefault());
private AuthenticationStrategy proxyAuthenticationStrategy;
Expand Down Expand Up @@ -242,6 +242,10 @@ public Builder proxy(HttpHost proxy, AuthenticationStrategy proxyAuthenticationS
}

public HttpClientConfig build() {
if (this.sslSocketFactory == null) {
// Lazily initialize if necessary, as the call can be expensive when done eagerly.
this.sslSocketFactory = SSLConnectionSocketFactory.getSocketFactory();
}
return new HttpClientConfig(this);
}

Expand Down