Skip to content

Commit 369c6b4

Browse files
committed
Fix race condition in tailable cursor test
1 parent 41a68b2 commit 369c6b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

driver-core/src/test/functional/com/mongodb/operation/QueryBatchCursorFunctionalSpecification.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,23 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
264264
def firstBatch = executeQuery(new BsonDocument('ts', new BsonDocument('$gte', new BsonTimestamp(5, 0))), 0, 2, true, true);
265265
cursor = new QueryBatchCursor<Document>(firstBatch, 0, 2, new DocumentCodec(), connectionSource)
266266
cursor.next()
267+
def latch = new CountDownLatch(1)
267268

268269
// wait a second then close the cursor
269270
new Thread({
270271
sleep(1000)
271272
cursor.close()
273+
latch.countDown()
272274
} as Runnable).start()
273275

274276
when:
275277
cursor.hasNext()
276278

277279
then:
278280
thrown(Exception)
281+
282+
cleanup:
283+
latch.await(5, TimeUnit.SECONDS) // wait for cursor.close to complete
279284
}
280285

281286
@IgnoreIf({ !serverVersionAtLeast(3, 2) || isSharded() })

0 commit comments

Comments
 (0)