Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stub: Deprecate StreamObservers #10654

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.ServerCallStreamObserver;
import io.grpc.stub.StreamObserver;
import io.grpc.stub.StreamObservers;
import io.grpc.testing.TlsTesting;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
Expand Down Expand Up @@ -282,6 +281,7 @@ public void onCompleted() {
}

@Override
@SuppressWarnings("deprecation") // For StreamObservers, ideally we refactor this class out.
public void streamingFromServer(
final Messages.SimpleRequest request,
final StreamObserver<Messages.SimpleResponse> observer) {
Expand All @@ -291,7 +291,7 @@ public void streamingFromServer(
(ServerCallStreamObserver<Messages.SimpleResponse>) observer;
// If the client cancels, copyWithFlowControl takes care of calling
// responseObserver.onCompleted() for us
StreamObservers.copyWithFlowControl(
io.grpc.stub.StreamObservers.copyWithFlowControl(
new Iterator<Messages.SimpleResponse>() {
@Override
public boolean hasNext() {
Expand All @@ -312,14 +312,15 @@ public void remove() {
}

@Override
@SuppressWarnings("deprecation") // For StreamObservers, ideally we refactor this class out.
public StreamObserver<Messages.SimpleRequest> streamingBothWays(
final StreamObserver<Messages.SimpleResponse> observer) {
// receive data forever and send data forever until client cancels or we shut down.
final ServerCallStreamObserver<Messages.SimpleResponse> responseObserver =
(ServerCallStreamObserver<Messages.SimpleResponse>) observer;
// If the client cancels, copyWithFlowControl takes care of calling
// responseObserver.onCompleted() for us
StreamObservers.copyWithFlowControl(
io.grpc.stub.StreamObservers.copyWithFlowControl(
new Iterator<Messages.SimpleResponse>() {
@Override
public boolean hasNext() {
Expand Down
3 changes: 3 additions & 0 deletions stub/src/main/java/io/grpc/stub/StreamObservers.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
/**
* Utility functions for working with {@link StreamObserver} and it's common subclasses like
* {@link CallStreamObserver}.
*
* @deprecated Of questionable utility and generally not used.
*/
@Deprecated
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4694")
public final class StreamObservers {
/**
Expand Down