Skip to content

Commit

Permalink
add comments, fix preconditions check
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Chen committed May 24, 2021
1 parent 61989c7 commit 47876e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -189,8 +189,9 @@ private Query getAllDescendantsQuery() {
// The parent is the closest ancestor document to the location we're deleting. Since we are
// deleting a document, the parent is the path of that document.
parentPath = path;
Preconditions.checkState(
path.getParent() != null, "Parent of a document should not be null.");
collectionId = path.getParent().getId();
Preconditions.checkState(collectionId != null, "Parent of a document should not be null.");
} else {
// The parent is the closest ancestor document to the location we're deleting. Since we are
// deleting a collection, the parent is the path of the document containing that collection
Expand Down
Expand Up @@ -389,6 +389,10 @@ public RunQueryResponse answer(InvocationOnMock invocation) throws Throwable {
public ApiFuture<BatchWriteResponse> answer(InvocationOnMock mock) throws Exception {
if (numDeletesBuffered[0] < cutoff) {
numDeletesBuffered[0] += batchWriteResponse.size();
// By waiting for `bufferFuture` to complete, we can guarantee that the writes
// complete after all documents are streamed. Without this future, the test can
// race and complete the writes before the stream is finished, which is a
// different scenario this test is not for.
return ApiFutures.transformAsync(
bufferFuture,
new ApiAsyncFunction<Void, BatchWriteResponse>() {
Expand Down

0 comments on commit 47876e8

Please sign in to comment.