@Test public void sendError() throws Exception { mThrown.expect(UnauthenticatedException.class); mThrown.expectMessage(containsString(TEST_MESSAGE)); mResponseObserver.onError(Status.UNAUTHENTICATED.asRuntimeException()); mStream.send(WriteRequest.newBuilder().build(), TIMEOUT); }
public void send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or cancelled.", LogUtils.truncateMessageLineLength(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLineLength(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLineLength(request)), e); } } } mRequestObserver.onNext(request); }
GrpcBlockingStream { public void send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or cancelled.", LogUtils.truncateMessageLineLength(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLineLength(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLineLength(request)), e); } } } mRequestObserver.onNext(request); } }
GrpcBlockingStream { public void send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or cancelled.", LogUtils.truncateMessageLineLength(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLineLength(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLineLength(request)), e); } } } mRequestObserver.onNext(request); } GrpcBlockingStream(Function<StreamObserver<ResT>, StreamObserver<ReqT>> rpcFunc,
      int bufferSize, String description); }
GrpcBlockingStream { public void send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or cancelled.", LogUtils.truncateMessageLineLength(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLineLength(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLineLength(request)), e); } } } mRequestObserver.onNext(request); } 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 send(ReqT request, long timeoutMs) throws IOException { if (mClosed || mCanceled || mClosedFromRemote) { throw new CancelledException( formatErrorMessage("Failed to send request %s: stream is already closed or cancelled.", LogUtils.truncateMessageLineLength(request))); } try (LockResource lr = new LockResource(mLock)) { while (true) { checkError(); if (mRequestObserver.isReady()) { break; } try { if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) { throw new DeadlineExceededException( formatErrorMessage("Timeout sending request %s after %dms.", LogUtils.truncateMessageLineLength(request), timeoutMs)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CancelledException( formatErrorMessage("Failed to send request %s: interrupted while waiting for server.", LogUtils.truncateMessageLineLength(request)), e); } } } mRequestObserver.onNext(request); } 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();  }