Skip to content

Commit

Permalink
stub: Deprecate StreamObservers (#10654)
Browse files Browse the repository at this point in the history
This class is of questionable utility and generally not used.
  • Loading branch information
temawi authored Nov 8, 2023
1 parent 3ca3b99 commit 0346b40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 0346b40

Please sign in to comment.