Skip to content

Commit 0f3bc0e

Browse files
Don't raise empty Snapshots on resets (googleapis#3750)
1 parent 63aff86 commit 0f3bc0e

File tree

2 files changed

+29
-1
lines changed
  • google-cloud-clients/google-cloud-firestore/src

2 files changed

+29
-1
lines changed

google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ public void run() {
406406
Preconditions.checkState(stream == null);
407407

408408
current = false;
409-
hasPushed = false;
410409
nextAttempt = backoff.createNextAttempt(nextAttempt);
411410

412411
stream = firestore.streamRequest(Watch.this, firestore.getClient().listenCallable());

google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WatchTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,35 @@ public void queryWatchReopensOnUnexceptedStreamEnd() throws InterruptedException
304304
awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc", SINGLE_FIELD_MAP));
305305
}
306306

307+
@Test
308+
public void queryWatchDoesntSendRaiseSnapshotOnReset() throws InterruptedException {
309+
// This test is meant to reproduce https://github.com/googleapis/google-cloud-dotnet/issues/2542
310+
addQueryListener();
311+
312+
awaitAddTarget();
313+
314+
send(addTarget());
315+
send(current());
316+
send(snapshot());
317+
318+
awaitQuerySnapshot();
319+
320+
close();
321+
awaitClose();
322+
awaitAddTarget();
323+
324+
send(addTarget());
325+
send(current());
326+
// This should not raise a snapshot, since nothing has changed since the last snapshot.
327+
send(snapshot());
328+
329+
send(doc("coll/doc", SINGLE_FIELD_PROTO));
330+
send(snapshot());
331+
332+
// Verify that we only receveived one snapshot.
333+
awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc", SINGLE_FIELD_MAP));
334+
}
335+
307336
@Test
308337
public void queryWatchDoesntReopenInactiveStream() throws InterruptedException {
309338
addQueryListener();

0 commit comments

Comments
 (0)