@@ -7,6 +7,7 @@ import com.mongodb.OperationFunctionalSpecification
77import com.mongodb.ServerCursor
88import com.mongodb.binding.ConnectionSource
99import com.mongodb.client.model.CreateCollectionOptions
10+ import com.mongodb.connection.Connection
1011import com.mongodb.connection.QueryResult
1112import org.bson.BsonDocument
1213import org.bson.BsonTimestamp
@@ -241,18 +242,15 @@ class QueryBatchCursorSpecification extends OperationFunctionalSpecification {
241242
242243 // 2.2 does not properly detect cursor not found, so ignoring
243244 @IgnoreIf ({ isSharded() && !serverVersionAtLeast([2 , 4 , 0 ]) })
244- @Category (Slow )
245245 def ' should kill cursor if limit is reached on initial query' () throws InterruptedException {
246246 given :
247247 def firstBatch = executeQuery(5 )
248248 def connection = connectionSource. getConnection()
249249
250250 cursor = new QueryBatchCursor<Document > (firstBatch, 5 , 0 , new DocumentCodec (), connectionSource, connection)
251251
252- Thread . sleep(1000 ) // Note: waiting for some time for killCursor operation to be performed on a server.
253-
254252 when :
255- makeAdditionalGetMoreCall(firstBatch. cursor)
253+ makeAdditionalGetMoreCall(firstBatch. cursor, connection )
256254
257255 then :
258256 thrown(MongoCursorNotFoundException )
@@ -429,9 +427,13 @@ class QueryBatchCursorSpecification extends OperationFunctionalSpecification {
429427 private void makeAdditionalGetMoreCall (ServerCursor serverCursor ) {
430428 def connection = connectionSource. getConnection()
431429 try {
432- connection . getMore(getNamespace(), serverCursor. getId(), 1 , new DocumentCodec () )
430+ makeAdditionalGetMoreCall( serverCursor, connection )
433431 } finally {
434432 connection. release()
435433 }
436434 }
435+
436+ private void makeAdditionalGetMoreCall (ServerCursor serverCursor , Connection connection ) {
437+ connection. getMore(getNamespace(), serverCursor. getId(), 1 , new DocumentCodec ())
438+ }
437439}
0 commit comments