KEMBAR78
fix: close the Watch stream when we receive an error by schmidt-sebastian · Pull Request #834 · googleapis/java-firestore · GitHub
Skip to content

Conversation

@schmidt-sebastian
Copy link
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 as a code owner 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
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
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
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
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
Collaborator

@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
Collaborator

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
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
Collaborator

Choose a reason for hiding this comment

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

Copy link
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 join this conversation on GitHub. Already have an account? Sign in to comment

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