@Test public void waitForComplete() throws Exception { WriteResponse[] responses = Stream.generate(() -> WriteResponse.newBuilder().build()) .limit(BUFFER_SIZE * 2).toArray(WriteResponse[]::new); EXECUTOR.submit(() -> { for (WriteResponse response : responses) { mResponseObserver.onNext(response); } try { Thread.sleep(SHORT_TIMEOUT); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } mResponseObserver.onCompleted(); }); WriteResponse actualResponse = mStream.receive(TIMEOUT); assertEquals(responses[0], actualResponse); mStream.waitForComplete(TIMEOUT); actualResponse = mStream.receive(TIMEOUT); assertEquals(null, actualResponse); }
public void waitForComplete(long timeoutMs) throws IOException { if (mCompleted || mCanceled) { return; } while (receive(timeoutMs) != null) { } }
GrpcBlockingStream { public void waitForComplete(long timeoutMs) throws IOException { if (mCompleted || mCanceled) { return; } while (receive(timeoutMs) != null) { } } }
GrpcBlockingStream { public void waitForComplete(long timeoutMs) throws IOException { if (mCompleted || mCanceled) { return; } while (receive(timeoutMs) != null) { } } GrpcBlockingStream(Function<StreamObserver<ResT>, StreamObserver<ReqT>> rpcFunc,
      int bufferSize, String description); }
GrpcBlockingStream { public void waitForComplete(long timeoutMs) throws IOException { if (mCompleted || mCanceled) { return; } while (receive(timeoutMs) != null) { } } GrpcBlockingStream(Function<StreamObserver<ResT>, StreamObserver<ReqT>> rpcFunc,
      int bufferSize, String description); void send(ReqT request, long timeoutMs); void send(ReqT request); ResT receive(long timeoutMs); void close(); void cancel(); void waitForComplete(long timeoutMs); boolean isClosedFromRemote(); boolean isOpen(); boolean isClosed(); boolean isCanceled(); }
GrpcBlockingStream { public void waitForComplete(long timeoutMs) throws IOException { if (mCompleted || mCanceled) { return; } while (receive(timeoutMs) != null) { } } GrpcBlockingStream(Function<StreamObserver<ResT>, StreamObserver<ReqT>> rpcFunc,
      int bufferSize, String description); void send(ReqT request, long timeoutMs); void send(ReqT request); ResT receive(long timeoutMs); void close(); void cancel(); void waitForComplete(long timeoutMs); boolean isClosedFromRemote(); boolean isOpen(); boolean isClosed(); boolean isCanceled();  }