risdenk commented on code in PR #829:
URL: https://github.com/apache/solr/pull/829#discussion_r863004649


##########
solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java:
##########
@@ -340,9 +370,13 @@ private void invokeBulkDeleteCall(int seed, 
ArrayList<String> errs) throws Excep
 
   private boolean checkCopyField(
       @SuppressWarnings({"rawtypes"}) List<Map> l, String src, String dest) {
-    if (l == null) return false;
+    if (l == null) {
+      return false;
+    }
     for (@SuppressWarnings({"rawtypes"}) Map map : l) {

Review Comment:
   addressed in 9389c95304d27d3b4308bc974e47df2260582ccf



##########
solr/core/src/test/org/apache/solr/schema/TestBulkSchemaConcurrent.java:
##########
@@ -51,39 +60,50 @@ protected String getCloudSolrConfig() {
     return "solrconfig-managed-schema.xml";
   }
 
+  @Before
+  public void setup() {
+    super.beforeTest();
+    setupRestTestHarnesses();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    closeRestTestHarnesses();
+    super.tearDown();
+  }
+
   @Test
-  @SuppressWarnings({"unchecked"})
   public void test() throws Exception {
+    final List<List<String>> collectErrors = Collections.synchronizedList(new 
ArrayList<>());
 
-    final int threadCount = 5;
-    setupRestTestHarnesses();
-    Thread[] threads = new Thread[threadCount];
-    @SuppressWarnings({"rawtypes"})
-    final List<List> collectErrors = Collections.synchronizedList(new 
ArrayList<>());
+    final ExecutorService executorService =
+        ExecutorUtil.newMDCAwareFixedThreadPool(
+            THREAD_COUNT, new 
SolrNamedThreadFactory(this.getClass().getSimpleName()));
 
-    for (int i = 0; i < threadCount; i++) {
+    List<Callable<Void>> callees = new ArrayList<>(THREAD_COUNT);
+    for (int i = 0; i < THREAD_COUNT; i++) {
       final int finalI = i;
-      threads[i] =
-          new Thread() {
-            @Override
-            public void run() {
-              @SuppressWarnings({"rawtypes"})
-              ArrayList errs = new ArrayList();
-              collectErrors.add(errs);
-              try {
-                invokeBulkAddCall(finalI, errs);
-                invokeBulkReplaceCall(finalI, errs);
-                invokeBulkDeleteCall(finalI, errs);
-              } catch (Exception e) {
-                e.printStackTrace();
-              }
+      Callable<Void> call =
+          () -> {
+            List<String> errs = new ArrayList<>();
+            collectErrors.add(errs);
+            try {
+              invokeBulkAddCall(finalI, errs);
+              invokeBulkReplaceCall(finalI, errs);
+              invokeBulkDeleteCall(finalI, errs);
+            } catch (Exception e) {
+              e.printStackTrace();
+              Thread.currentThread().interrupt();
             }
+            return null;
           };
-
-      threads[i].start();
+      callees.add(call);
     }
 
-    for (Thread thread : threads) thread.join();
+    executorService.invokeAll(callees);
+    executorService.shutdown();
+    assertTrue(
+        "Running for too long...", executorService.awaitTermination(TIMEOUT * 
3, TimeUnit.SECONDS));
 
     boolean success = true;
 

Review Comment:
   addressed in 9389c95304d27d3b4308bc974e47df2260582ccf



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