|
@@ -27,7 +27,6 @@ import org.elasticsearch.common.Nullable;
|
|
|
import org.elasticsearch.common.compress.CompressedXContent;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
-import org.elasticsearch.common.util.concurrent.CountDown;
|
|
|
import org.elasticsearch.common.xcontent.ToXContent;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
|
@@ -43,7 +42,6 @@ import java.io.IOException;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
-import java.util.function.BiFunction;
|
|
|
|
|
|
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
|
|
import static org.hamcrest.Matchers.containsString;
|
|
@@ -190,18 +188,12 @@ public class IndexServiceTests extends ESSingleNodeTestCase {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- BiFunction<AtomicReference<CountDownLatch>, CountDownLatch, CountDownLatch> swapAndReturn = (ref, newLatch) -> {
|
|
|
- CountDownLatch downLatch = ref.get();
|
|
|
- ref.set(newLatch);
|
|
|
- return downLatch;
|
|
|
- };
|
|
|
latch.get().await();
|
|
|
- swapAndReturn.apply(latch, new CountDownLatch(1));
|
|
|
+ latch.set(new CountDownLatch(1));
|
|
|
assertEquals(1, count.get());
|
|
|
// here we need to swap first before we let it go otherwise threads might be very fast and run that task twice due to
|
|
|
// random exception and the schedule interval is 1ms
|
|
|
- swapAndReturn.apply(latch2, new CountDownLatch(1)).countDown();
|
|
|
-
|
|
|
+ latch2.getAndSet(new CountDownLatch(1)).countDown();
|
|
|
latch.get().await();
|
|
|
assertEquals(2, count.get());
|
|
|
task.close();
|