Skip to content

Commit

Permalink
static method nextAndComplete()
Browse files Browse the repository at this point in the history
  • Loading branch information
panchenko committed Dec 24, 2024
1 parent ebe2b48 commit 026002a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions stub/src/main/java/io/grpc/stub/StreamObservers.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@
/**
* 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 {
/**
* Utility method to call {@link StreamObserver#onNext(Object)} and
* {@link StreamObserver#onCompleted()} on the specified responseObserver.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10957")
public static <T> void nextAndComplete(StreamObserver<T> responseObserver, T response) {
Preconditions.checkNotNull(response, "response");

Check warning on line 34 in stub/src/main/java/io/grpc/stub/StreamObservers.java

View check run for this annotation

Codecov / codecov/patch

stub/src/main/java/io/grpc/stub/StreamObservers.java#L34

Added line #L34 was not covered by tests

responseObserver.onNext(response);
responseObserver.onCompleted();
}

Check warning on line 38 in stub/src/main/java/io/grpc/stub/StreamObservers.java

View check run for this annotation

Codecov / codecov/patch

stub/src/main/java/io/grpc/stub/StreamObservers.java#L36-L38

Added lines #L36 - L38 were not covered by tests

/**
* Copy the values of an {@link Iterator} to the target {@link CallStreamObserver} while properly
* accounting for outbound flow-control. After calling this method, {@code target} should no
Expand All @@ -40,7 +48,10 @@ public final class StreamObservers {
*
* @param source of values expressed as an {@link Iterator}.
* @param target {@link CallStreamObserver} which accepts values from the source.
* @deprecated Of questionable utility and generally not used.
*/
@Deprecated
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4694")
public static <V> void copyWithFlowControl(final Iterator<V> source,
final CallStreamObserver<V> target) {
Preconditions.checkNotNull(source, "source");
Expand Down Expand Up @@ -80,7 +91,10 @@ public void run() {
*
* @param source of values expressed as an {@link Iterable}.
* @param target {@link CallStreamObserver} which accepts values from the source.
* @deprecated Of questionable utility and generally not used.
*/
@Deprecated
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4694")
public static <V> void copyWithFlowControl(final Iterable<V> source,
CallStreamObserver<V> target) {
Preconditions.checkNotNull(source, "source");
Expand Down

0 comments on commit 026002a

Please sign in to comment.