dsmiley commented on code in PR #2714:
URL: https://github.com/apache/solr/pull/2714#discussion_r1779367542
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -533,6 +535,47 @@ public NamedList<Object> request(SolrRequest<?>
solrRequest, String collection)
}
}
+ public final <T extends SolrResponse> T requestWithBaseUrl(String baseUrl,
SolrRequest<T> req)
+ throws SolrServerException, IOException {
+ return requestWithBaseUrl(baseUrl, req::process);
+ }
+
+ /**
+ * Temporarily modifies the client to use a different base URL and runs the
provided lambda
+ *
+ * @param baseUrl the base URL to use on any requests made within the
'clientFunction' lambda
+ * @param clientFunction a Function that consumes a Http2SolrClient and
returns an arbitrary value
+ * @return the value returned after invoking 'clientFunction'
+ * @param <R> the type returned by the provided function (and by this method)
+ */
+ public <R> R requestWithBaseUrl(String baseUrl,
SolrClientFunction<SolrClient, R> clientFunction)
+ throws SolrServerException, IOException {
+ try (final var derivedClient = new NoCloseHttp2SolrClient(baseUrl, this)) {
Review Comment:
why try-finally here? ;-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]