Source:
public FindResult getNextEntriesAndUpdatedToken(FindToken curFindToken, long maxTotalSizeOfEntries, String partitionPath) throws DocumentClientException { List<CloudBlobMetadata> nextEntries = new ArrayList<>(); CosmosChangeFeedFindToken cosmosChangeFeedFindToken = (CosmosChangeFeedFindToken) curFindToken; int index = cosmosChangeFeedFindToken.getIndex(); String cacheSesionId = cosmosChangeFeedFindToken.getCacheSessionId(); if (!changeFeedCache.containsKey(cacheSesionId) || !isCacheValid(partitionPath, cosmosChangeFeedFindToken)) { cacheSesionId = populateChangeFeedCache(partitionPath, cosmosChangeFeedFindToken.getStartContinuationToken()); changeFeedCache.remove(cosmosChangeFeedFindToken.getCacheSessionId()); index = 0; } long resultSize = 0; List<CloudBlobMetadata> fetchedEntries = changeFeedCache.get(cacheSesionId).getFetchedEntries(); while (true) { if (index < fetchedEntries.size()) { if (resultSize + fetchedEntries.get(index).getSize() < maxTotalSizeOfEntries || resultSize == 0) { nextEntries.add(fetchedEntries.get(index)); resultSize = resultSize + fetchedEntries.get(index).getSize(); index++; } else { break; } } else { populateChangeFeedCache(partitionPath, cosmosChangeFeedFindToken.getEndContinuationToken(), cosmosChangeFeedFindToken.getCacheSessionId()); fetchedEntries = changeFeedCache.get(cacheSesionId).getFetchedEntries(); if (fetchedEntries.isEmpty()) { break; } index = 0; } } FindToken updatedToken = new CosmosChangeFeedFindToken(cosmosChangeFeedFindToken.getBytesRead() + resultSize, changeFeedCache.get(cacheSesionId).getStartContinuationToken(), changeFeedCache.get(cacheSesionId).getEndContinuationToken(), index, changeFeedCache.get(cacheSesionId).getFetchedEntries().size(), cacheSesionId, cosmosChangeFeedFindToken.getVersion()); return new FindResult(nextEntries, updatedToken); }

Target:
public FindResult getNextEntriesAndUpdatedToken(FindToken curFindToken, long maxTotalSizeOfEntries, String partitionPath) throws DocumentClientException { List<CloudBlobMetadata> nextEntries = new ArrayList<>(); CosmosChangeFeedFindToken cosmosChangeFeedFindToken = (CosmosChangeFeedFindToken) curFindToken; int index = cosmosChangeFeedFindToken.getIndex(); ChangeFeedCacheEntry changeFeedCacheEntry = changeFeedCache.get(cosmosChangeFeedFindToken.getCacheSessionId()); if (changeFeedCacheEntry == null || !isCacheValid(partitionPath, cosmosChangeFeedFindToken, changeFeedCacheEntry)) { changeFeedCacheEntry = getNextChangeFeed(partitionPath, cosmosChangeFeedFindToken.getStartContinuationToken()); changeFeedCache.remove(cosmosChangeFeedFindToken.getCacheSessionId()); index = 0; } long resultSize = 0; List<CloudBlobMetadata> fetchedEntries = changeFeedCacheEntry.getFetchedEntries(); while (true) { if (index < fetchedEntries.size()) { if (resultSize + fetchedEntries.get(index).getSize() < maxTotalSizeOfEntries || resultSize == 0) { nextEntries.add(fetchedEntries.get(index)); resultSize = resultSize + fetchedEntries.get(index).getSize(); index++; } else { break; } } else { changeFeedCacheEntry = getNextChangeFeed(partitionPath, changeFeedCacheEntry.getEndContinuationToken(), changeFeedCacheEntry.getCacheSessionId()); fetchedEntries = changeFeedCacheEntry.getFetchedEntries(); if (fetchedEntries.isEmpty()) { break; } index = 0; } } FindToken updatedToken = new CosmosChangeFeedFindToken(cosmosChangeFeedFindToken.getBytesRead() + resultSize, changeFeedCacheEntry.getStartContinuationToken(), changeFeedCacheEntry.getEndContinuationToken(), index, changeFeedCacheEntry.getFetchedEntries().size(), changeFeedCacheEntry.getCacheSessionId(), cosmosChangeFeedFindToken.getVersion()); changeFeedCache.put(changeFeedCacheEntry.getCacheSessionId(), new ChangeFeedCacheEntry(changeFeedCacheEntry)); return new FindResult(nextEntries, updatedToken); }