question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document CallStreamObserver.request() thread-safety

See original GitHub issue

What version of gRPC are you using?

1.5.0

The javadoc for CallStreamObserver.request() makes no statement about thread safety. I see that the applicable implementations call request() methods that are documented as thread-safe, and that CallStreamObserver.request() is called as if it were thread-safe. I assume that this is meant to be a contract, as otherwise usage would be oddly complicated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ejona86commented, Aug 30, 2017

To be useful, request() must be thread-safe. Yes, we need to update the documentation.

ClientCall specifies for request():

This method is safe to call from multiple threads without external synchronizaton.

We should include something similar in CallStreamObserver.

0reactions
ejona86commented, Aug 30, 2017

To round it out, isReady() and setMessageCompression() - those actually sound thread-compatible.

Correct. They are not thread-safe.

We should probably just copy the same “Implementations are expected to be thread-compatible” doc to CallStreamObserver (and children). Then we just call out in request()'s documentation that it is thread-safe. Same approach as in ClientCall.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StreamObserver (grpc-all 1.51.0 API)
Receives notifications from an observable stream of messages. It is used by both the client stubs and service implementations for sending or receiving ......
Read more >
ServerCallStreamObserver (grpc-stub 1.22.1 API) - javadoc.io
A refinement of CallStreamObserver to allows for interaction with call ... Like StreamObserver , implementations are not required to be thread-safe; ...
Read more >
Can gRPC Java client send multiple requests in parallel over ...
when sending messages, you should respect other side's readiness using methods from CallStreamObserver: isReady() and setOnReadyHandler(...) (you can always ...
Read more >
Effective Java: Document Thread Safety | by Kyle Carter | CodeX
synchronized wrappers that synchronize much of interactions with the object but do require external synchronization of iterators returned. Not ...
Read more >
io.grpc.stub.CallStreamObserver java code examples - Tabnine
BlockingStreamObserver(CallStreamObserver<T> delegate) { this.delegate = delegate; final Runnable notifyAll = () -> { synchronized (lock) { lock.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found