Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

fix: close the Watch stream when we receive an error#834

Merged
schmidt-sebastian merged 3 commits into
mainfrom
mrschmidt/closestream
Jan 27, 2022
Merged

fix: close the Watch stream when we receive an error#834
schmidt-sebastian merged 3 commits into
mainfrom
mrschmidt/closestream

Conversation

@schmidt-sebastian
Copy link
Copy Markdown
Contributor

@schmidt-sebastian schmidt-sebastian commented Dec 20, 2021

The Watch code called "onCompleted" to close the stream - but that did not actually do anything. This PR migrates our streaming GAPIC APIs to ClientStream (which is not deprecated) and then calls "close()" instead.

Fixes: #822

@schmidt-sebastian schmidt-sebastian requested a review from a team December 20, 2021 23:00
@product-auto-label product-auto-label Bot added the api: firestore Issues related to the googleapis/java-firestore API. label Dec 20, 2021
Comment on lines +53 to +57
ResponseObserver<ResponseT> responseObserverT,
ServerStreamingCallable<RequestT, ResponseT> callable);

<RequestT, ResponseT> ApiStreamObserver<RequestT> streamRequest(
ApiStreamObserver<ResponseT> responseObserverT,
<RequestT, ResponseT> ClientStream<RequestT> streamRequest(
BidiStreamObserver<RequestT, ResponseT> responseObserverT,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the main changes, the rest is plumbing and cleanup.

() -> {
synchronized (Watch.this) {
stream.onCompleted();
stream.closeSend();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now closes the stream instead of invoking a no-op method.

} else {
return queryResponse(DOCUMENT_NAME + "3").answer(invocation);
}
})
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Here and below - this is only a formatting change as I removed the unused cast.

MoreExecutors.directExecutor());
}
})
mock -> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a formatting change.

Copy link
Copy Markdown
Contributor

@kolea2 kolea2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look fine. Just a few questions around testing

retryAttempts[0]++;
return RETRYABLE_FAILED_FUTURE;
})
mock -> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this test the new changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's hard to test these changes. We could mock the backend stream, but then we are essentially only testing the behavior of the mock. If you know of a pre-existing implementation/fake of a GRPC stream that we can use to test this behavior, then we can add a test. A homegrown implementation that validates that our code follows our ow assumptions will not provide us with much meaningful test coverage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test queryWatchShutsDownStreamOnPermissionDenied() that re-uses some of the existing functionality.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: firestore Issues related to the googleapis/java-firestore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshot listener gets a regular callback with 'Received unexpected EOS on empty DATA frame from server' exception

2 participants