Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private List<T> doNext() {

List<T> retVal = nextBatch;
nextBatch = null;
commandCursorResult = CommandCursorResult.withEmptyResults(commandCursorResult);
return retVal;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.bson.BsonDocument;
import org.bson.BsonTimestamp;

import java.util.Collections;
import java.util.List;

import static com.mongodb.assertions.Assertions.isTrue;
Expand Down Expand Up @@ -60,6 +61,31 @@ public CommandCursorResult(
this.postBatchResumeToken = cursorDocument.getDocument(POST_BATCH_RESUME_TOKEN, null);
}

private CommandCursorResult(
final ServerAddress serverAddress,
final List<T> results,
final MongoNamespace namespace,
final long cursorId,
@Nullable final BsonTimestamp operationTime,
@Nullable final BsonDocument postBatchResumeToken) {
this.serverAddress = serverAddress;
this.results = results;
this.namespace = namespace;
this.cursorId = cursorId;
this.operationTime = operationTime;
this.postBatchResumeToken = postBatchResumeToken;
}

public static <T> CommandCursorResult<T> withEmptyResults(final CommandCursorResult<T> commandCursorResult) {
return new CommandCursorResult<>(
commandCursorResult.getServerAddress(),
Collections.emptyList(),
commandCursorResult.getNamespace(),
commandCursorResult.getCursorId(),
commandCursorResult.getOperationTime(),
commandCursorResult.getPostBatchResumeToken());
}

/**
* Gets the namespace.
*
Expand Down