Skip to content

Commit

Permalink
Add attemptJava5516 - a non-deterministic reproducer
Browse files Browse the repository at this point in the history
  • Loading branch information
stIncMale committed Jul 9, 2024
1 parent 88b4218 commit b7be8c8
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -299,6 +300,24 @@ void testLimitWithGetMore() {
assertTrue(cursor.isClosed());
}

@Test
void attemptJava5516() {
BsonDocument commandResult = executeFindCommand(5, 2);
cursor = new AsyncCommandBatchCursor<>(commandResult, 2, 0, DOCUMENT_DECODER,
null, connectionSource, connection);
assertNotNull(cursorNext());
// Calling `close` twice is the key to reproducing.
// It does not matter whether we call `close` twice from the same thread or not.
ForkJoinPool.commonPool().execute(() -> cursor.close());
ForkJoinPool.commonPool().execute(() -> cursor.close());
try {
assertNotNull(cursorNext());
assertNotNull(cursorNext());
} catch (IllegalStateException e) {
// one of the expected outcomes, because we call `cursorNext` concurrently with `close`
}
}

@Test
@DisplayName("test limit with large documents")
void testLimitWithLargeDocuments() {
Expand Down

0 comments on commit b7be8c8

Please sign in to comment.