Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that resumeToken is included on resume attempts #634

Merged
merged 3 commits into from Jan 20, 2021

Conversation

jyemin
Copy link
Contributor

@jyemin jyemin commented Jan 14, 2021

@jyemin jyemin self-assigned this Jan 14, 2021
// check equality in the case where the batch has not been iterated at all
assertEquals(cursor.getResumeToken(), batchCursor.getPostBatchResumeToken());
// resume token should be null before iteration
assertNull(cursor.getResumeToken());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was wrong. Before the bug fix, both the values were null. Afterwards, the postBatchResumeToken is set on the batch cursor but not the high-level cursor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you add a assertNotNull(batchCursor.getPostBatchResumeToken()) check as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -100,6 +100,7 @@
this.decoder = notNull("decoder", decoder);
if (result != null) {
this.operationTime = result.getTimestamp(OPERATION_TIME, null);
this.postBatchResumeToken = getPostBatchResumeTokenFromResponse(result);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it matches AsyncQueryBatchCursor constructor

return queryBatchCursor.hasNext();
try {
return queryBatchCursor.hasNext();
} catch (RuntimeException e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might also be ok for this to be a finally block, but I wasn't able to convince myself of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm interested as to why do it this way? Personally, I'd convert to a finally block as its cleaner and in my head equates to the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I convinced myself it's ok for this to be a finally block.

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits

return queryBatchCursor.hasNext();
try {
return queryBatchCursor.hasNext();
} catch (RuntimeException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm interested as to why do it this way? Personally, I'd convert to a finally block as its cleaner and in my head equates to the same thing.

// check equality in the case where the batch has not been iterated at all
assertEquals(cursor.getResumeToken(), batchCursor.getPostBatchResumeToken());
// resume token should be null before iteration
assertNull(cursor.getResumeToken());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you add a assertNotNull(batchCursor.getPostBatchResumeToken()) check as well?

@@ -51,8 +50,6 @@ public UnifiedTestValidator(final String fileDescription, final String testDescr

@Before
public void setUp() {
// TODO: remove after https://jira.mongodb.org/browse/JAVA-3871 is fixed
assumeTrue(!(fileDescription.equals("poc-change-streams") && testDescription.equals("Test consecutive resume")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hurrah!

@jyemin jyemin requested a review from rozza January 20, 2021 00:13
Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jyemin jyemin merged commit 1c318a6 into mongodb:master Jan 20, 2021
@jyemin jyemin deleted the j3871-fix branch January 20, 2021 14:31
jyemin added a commit to jyemin/mongo-java-driver that referenced this pull request Jan 20, 2021
jfitzu pushed a commit to nextworld-tools/mongo-java-driver that referenced this pull request Mar 3, 2021
jfitzu added a commit to nextworld-tools/mongo-java-driver that referenced this pull request Mar 3, 2021
ispringer pushed a commit to evergage/mongo-java-driver that referenced this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants