simplify test to not use lambda at all

This commit is contained in:
Simon Willnauer 2016-03-24 16:48:50 +01:00
parent 49d868b491
commit f81fb89ea5
1 changed files with 2 additions and 10 deletions

View File

@ -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();