浏览代码

Remove redundant LatchedActionListener from ESIntegTestCase (#121244) (#121262)

This is effectively the same as the other class. The logging is
irrelevant and the dead `addError` is too => lets remove this.
Armin Braun 8 月之前
父节点
当前提交
1261557a38
共有 1 个文件被更改,包括 6 次插入30 次删除
  1. 6 30
      test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

+ 6 - 30
test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

@@ -26,6 +26,7 @@ import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
 import org.elasticsearch.action.ActionType;
 import org.elasticsearch.action.DocWriteResponse;
+import org.elasticsearch.action.LatchedActionListener;
 import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest;
 import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse;
 import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction;
@@ -1711,7 +1712,8 @@ public abstract class ESIntegTestCase extends ESTestCase {
                 logger.info("Index [{}] docs async: [{}] bulk: [{}]", builders.size(), true, false);
                 for (IndexRequestBuilder indexRequestBuilder : builders) {
                     indexRequestBuilder.execute(
-                        new LatchedActionListener<DocWriteResponse>(newLatch(inFlightAsyncOperations)).delegateResponse((l, e) -> fail(e))
+                        new LatchedActionListener<DocWriteResponse>(ActionListener.noop(), newLatch(inFlightAsyncOperations))
+                            .delegateResponse((l, e) -> fail(e))
                     );
                     postIndexAsyncActions(indicesArray, inFlightAsyncOperations, maybeFlush);
                 }
@@ -1803,17 +1805,17 @@ public abstract class ESIntegTestCase extends ESTestCase {
             if (rarely()) {
                 indicesAdmin().prepareRefresh(indices)
                     .setIndicesOptions(IndicesOptions.lenientExpandOpen())
-                    .execute(new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
+                    .execute(new LatchedActionListener<>(ActionListener.noop(), newLatch(inFlightAsyncOperations)));
             } else if (maybeFlush && rarely()) {
                 indicesAdmin().prepareFlush(indices)
                     .setIndicesOptions(IndicesOptions.lenientExpandOpen())
-                    .execute(new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
+                    .execute(new LatchedActionListener<>(ActionListener.noop(), newLatch(inFlightAsyncOperations)));
             } else if (rarely()) {
                 indicesAdmin().prepareForceMerge(indices)
                     .setIndicesOptions(IndicesOptions.lenientExpandOpen())
                     .setMaxNumSegments(between(1, 10))
                     .setFlush(maybeFlush && randomBoolean())
-                    .execute(new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
+                    .execute(new LatchedActionListener<>(ActionListener.noop(), newLatch(inFlightAsyncOperations)));
             }
         }
         while (inFlightAsyncOperations.size() > MAX_IN_FLIGHT_ASYNC_INDEXES) {
@@ -1897,32 +1899,6 @@ public abstract class ESIntegTestCase extends ESTestCase {
         int numClientNodes() default InternalTestCluster.DEFAULT_NUM_CLIENT_NODES;
     }
 
-    private class LatchedActionListener<Response> implements ActionListener<Response> {
-        private final CountDownLatch latch;
-
-        LatchedActionListener(CountDownLatch latch) {
-            this.latch = latch;
-        }
-
-        @Override
-        public final void onResponse(Response response) {
-            latch.countDown();
-        }
-
-        @Override
-        public final void onFailure(Exception t) {
-            try {
-                logger.info("Action Failed", t);
-                addError(t);
-            } finally {
-                latch.countDown();
-            }
-        }
-
-        protected void addError(Exception e) {}
-
-    }
-
     /**
      * Clears the given scroll Ids
      */