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
Conversation
...functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy
Show resolved
Hide resolved
// 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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
...functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy
Show resolved
Hide resolved
// 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()); |
There was a problem hiding this comment.
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"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hurrah!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
JAVA-3871