dsmiley commented on code in PR #2805:
URL: https://github.com/apache/solr/pull/2805#discussion_r1820061320


##########
solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientIntegrationTest.java:
##########
@@ -119,22 +114,45 @@ public void tearDown() throws Exception {
         aSolr.tearDown();
       }
     }
-    httpClient.close();
     super.tearDown();
   }
 
+  private LBClientHolder client(LBSolrClient.Endpoint... baseSolrEndpoints) {
+    if (random().nextBoolean()) {
+      var delegateClient =
+          new Http2SolrClient.Builder()
+              .withConnectionTimeout(1000, TimeUnit.MILLISECONDS)
+              .withIdleTimeout(2000, TimeUnit.MILLISECONDS)
+              .build();
+      var lbClient =
+          new LBHttp2SolrClient.Builder(delegateClient, baseSolrEndpoints)
+              .withDefaultCollection(solr[0].getDefaultCollection())
+              .setAliveCheckInterval(500, TimeUnit.MILLISECONDS)
+              .build();
+      return new LBClientHolder(lbClient, delegateClient);
+    } else {
+      var delegateClient =
+          new HttpJdkSolrClient.Builder()
+              .withConnectionTimeout(1000, TimeUnit.MILLISECONDS)
+              .withIdleTimeout(2000, TimeUnit.MILLISECONDS)
+              .build();
+      var lbClient =
+          new LBHttpJdkSolrClient.Builder(delegateClient, baseSolrEndpoints)
+              .withDefaultCollection(solr[0].getDefaultCollection())
+              .setAliveCheckInterval(500, TimeUnit.MILLISECONDS)
+              .build();
+      return new LBClientHolder(lbClient, delegateClient);
+    }
+  }
+
   public void testSimple() throws Exception {
     final var baseSolrEndpoints = bootstrapBaseSolrEndpoints(solr.length);
-    try (LBHttp2SolrClient client =
-        new LBHttp2SolrClient.Builder(httpClient, baseSolrEndpoints)
-            .withDefaultCollection(solr[0].getDefaultCollection())
-            .setAliveCheckInterval(500, TimeUnit.MILLISECONDS)
-            .build()) {
+    try (var h = client(baseSolrEndpoints)) {

Review Comment:
   h?  the type isn't clear enough to use 'var' if the name is merely 'h'.



##########
solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientIntegrationTest.java:
##########
@@ -337,8 +349,27 @@ public void startJetty() throws Exception {
         fail("TESTING FAILURE: could not grab requested port.");
       }
       this.port = newPort;
-      //      System.out.println("waiting.........");
-      //      Thread.sleep(5000);
+    }
+  }
+
+  private static class LBClientHolder implements AutoCloseable {

Review Comment:
   Wouldn't closing lbClient close the delegate?  If it doesn't, shouldn't it?  
 Then LBClientHolder could go away.



-- 
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]

Reply via email to