Skip to content

Commit

Permalink
Avoid unnecessary http client creation (#480)
Browse files Browse the repository at this point in the history
Avoid unnecessarily creating an http client when configuring the AuthAPI cient
  • Loading branch information
jimmyjames committed Dec 7, 2022
1 parent f2ba6d3 commit 2a545c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/auth0/client/auth/AuthAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ public static class Builder {
private final String domain;
private final String clientId;
private final String clientSecret;
private Auth0HttpClient httpClient = DefaultHttpClient.newBuilder().build();
private Auth0HttpClient httpClient;

/**
* Create a new Builder
Expand Down Expand Up @@ -969,7 +969,8 @@ public Builder withHttpClient(Auth0HttpClient httpClient) {
* @return the configured {@code AuthAPI} instance.
*/
public AuthAPI build() {
return new AuthAPI(domain, clientId, clientSecret, httpClient);
return new AuthAPI(domain, clientId, clientSecret,
Objects.nonNull(httpClient) ? httpClient : DefaultHttpClient.newBuilder().build());
}
}
}

0 comments on commit 2a545c3

Please sign in to comment.