iamsanjay commented on code in PR #2689:
URL: https://github.com/apache/solr/pull/2689#discussion_r1742146196


##########
solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java:
##########
@@ -347,22 +348,27 @@ PublicKey fetchPublicKeyFromRemote(String nodename) {
     HttpEntity entity = null;
     try {
       String uri = url + PublicKeyHandler.PATH + "?wt=json&omitHeader=true";
+      ModifiableSolrParams solrParams = new ModifiableSolrParams();
+      solrParams.add("wt", "json");
+      solrParams.add("omitHeader", "true");
+
+      GenericSolrRequest request =
+          new GenericSolrRequest(SolrRequest.METHOD.GET, 
PublicKeyHandler.PATH, solrParams);
+
       log.debug("Fetching fresh public key from: {}", uri);
-      HttpResponse rsp =
-          cores
-              .getUpdateShardHandler()
-              .getDefaultHttpClient()
-              .execute(new HttpGet(uri), 
HttpClientUtil.createNewHttpClientRequestContext());
-      entity = rsp.getEntity();
-      byte[] bytes = EntityUtils.toByteArray(entity);
-      Map<?, ?> m = (Map<?, ?>) Utils.fromJSON(bytes);
-      String key = (String) m.get("key");
-      if (key == null) {
-        log.error("No key available from {}{}", url, PublicKeyHandler.PATH);
-        return null;
-      } else {
-        log.info("New key obtained from node={}, key={}", nodename, key);
+
+      String key;
+      try (Http2SolrClient solrClient = new 
Http2SolrClient.Builder(url).build()) {

Review Comment:
   I was setting up the base path and initially used the 
`SolrRequest.setBasePath` method, which is now deprecated. I then tried to find 
a way to set the base path without using the deprecated API and remembered that 
we can recreate the builder with a URL to handle it. However, I know the 
consensus was to avoid repeatedly creating Http2SolrClient. Is there another 
way I can set the base path?



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to