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

Fixing the response header 'x-ms-continuation' value issue. #27377

Merged
merged 2 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -90,7 +90,6 @@ public boolean test(FeedResponse<T> frp) {

private volatile int collectedItems = 0;
private volatile boolean lastPage = false;

@Override
public FeedResponse<T> apply(FeedResponse<T> t) {

Expand All @@ -101,9 +100,15 @@ public FeedResponse<T> apply(FeedResponse<T> t) {
if (top != collectedItems) {
// Add Take Continuation Token
String sourceContinuationToken = t.getContinuationToken();
TakeContinuationToken takeContinuationToken = new TakeContinuationToken(top - collectedItems,
if (sourceContinuationToken != null) {
TakeContinuationToken takeContinuationToken = new TakeContinuationToken(top - collectedItems,
sourceContinuationToken);
headers.put(HttpConstants.HttpHeaders.CONTINUATION, takeContinuationToken.toJson());
headers.put(HttpConstants.HttpHeaders.CONTINUATION, takeContinuationToken.toJson());
} else {
// Null out the continuation token. The sourceContinuationToken being null means
// that this is the last page and there are no more elements left to fetch.
headers.put(HttpConstants.HttpHeaders.CONTINUATION, null);
}
} else {
// Null out the continuation token
headers.put(HttpConstants.HttpHeaders.CONTINUATION, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public void queryDocumentsWithTopContinuationTokens() throws Exception {
this.queryWithContinuationTokensAndPageSizes(query, new int[] { 1, 5, 10 }, 8);
}

@Test(groups = { "simple" }, timeOut = TIMEOUT * 1000, retryAnalyzer = RetryAnalyzer.class)
public void queryDocumentsWithTopGreaterThanItemsContinuationTokens() throws Exception {
String query = "SELECT TOP 2147483647 * FROM c";
this.queryWithContinuationTokensAndPageSizes(query, new int[] {1}, 20);
}

private void queryWithContinuationTokensAndPageSizes(String query, int[] pageSizes, int topCount) {
for (int pageSize : pageSizes) {
List<InternalObjectNode> receivedDocuments = this.queryWithContinuationTokens(query, pageSize);
Expand Down