Skip to content

Commit

Permalink
implement code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jdyer1 committed Dec 10, 2024
1 parent 19577dc commit ca59536
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,23 @@ private LBHttp2SolrClient(Builder<?> builder) {
if (builder.solrClientBuilder.urlParamNames == null) {
this.urlParamNames = Collections.emptySet();
} else {
this.urlParamNames = Collections.unmodifiableSet(builder.solrClientBuilder.urlParamNames);
this.urlParamNames = Set.copyOf(builder.solrClientBuilder.urlParamNames);
}
}

private synchronized HttpSolrClientBase buildClient(Endpoint endpoint) {
var client = urlToClient.get(endpoint.toString());
if (client == null) {
String tmpBaseSolrUrl = solrClientBuilder.baseSolrUrl;
solrClientBuilder.baseSolrUrl = endpoint.getBaseUrl();
client = solrClientBuilder.build();
urlToClient.put(endpoint.getBaseUrl(), client);
solrClientBuilder.baseSolrUrl = tmpBaseSolrUrl;
}
private HttpSolrClientBase buildClient(Endpoint endpoint) {
String tmpBaseSolrUrl = solrClientBuilder.baseSolrUrl;
solrClientBuilder.baseSolrUrl = endpoint.getBaseUrl();
var client = solrClientBuilder.build();
urlToClient.put(endpoint.getBaseUrl(), client);
solrClientBuilder.baseSolrUrl = tmpBaseSolrUrl;
return client;
}

@Override
protected HttpSolrClientBase getClient(Endpoint endpoint) {
var client = urlToClient.get(endpoint.getBaseUrl());
protected HttpSolrClientBase getClient(final Endpoint endpoint) {
var client =
urlToClient.computeIfAbsent(endpoint.getBaseUrl(), s -> this.buildClient(endpoint));
if (client == null) {
return buildClient(endpoint);
}
Expand All @@ -162,9 +160,7 @@ public Set<String> getUrlParamNames() {
@Override
public void close() {
super.close();
for (HttpSolrClientBase client : urlToClient.values()) {
IOUtils.closeQuietly(client);
}
urlToClient.values().forEach(IOUtils::closeQuietly);
}

/**
Expand Down

0 comments on commit ca59536

Please sign in to comment.