ibilley7 commented on code in PR #5801:
URL: https://github.com/apache/accumulo/pull/5801#discussion_r2279726921


##########
test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java:
##########
@@ -202,6 +204,60 @@ public void createTable() throws TableExistsException, 
AccumuloException,
     accumuloClient.tableOperations().delete(tableName);
   }
 
+  @Test
+  public void testDefendAgainstThreadsCreateSameTableNameConcurrently()
+      throws ExecutionException, InterruptedException {
+
+    ExecutorService pool = Executors.newFixedThreadPool(64);
+
+    for (int i = 0; i < 30; i++) {
+      String tablename = "t" + i;
+      List<Future<String>> futureList = new ArrayList<>();
+
+      CountDownLatch startSignal = new CountDownLatch(1);
+      CountDownLatch doneSignal = new CountDownLatch(10);
+
+      for (int j = 0; j < 10; j++) {
+        Future<String> future = pool.submit(() -> {
+          String result;
+          try {
+            startSignal.await();
+            accumuloClient.tableOperations().create(tablename);
+            result = "success";
+          } catch (TableExistsException e) {
+            result = "fail";
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            result = "fail";
+          } finally {
+            doneSignal.countDown();
+          }
+          return result;
+        });
+        futureList.add(future);
+      }
+
+      startSignal.countDown();
+
+      doneSignal.await();
+
+      int taskSucceeded = 0;
+      int taskFailed = 0;
+      for (Future<String> result : futureList) {
+        if (result.get().equals("success")) {
+          taskSucceeded++;
+        } else {
+          taskFailed++;
+        }
+      }

Review Comment:
   I thought of that, but the argument in Future can't be a primitive type.



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

Reply via email to