@Test @DisplayName("create proper error-forwarding observer") void createErrorForwardingObserver() { MemoizingObserver delegate = new MemoizingObserver<>(); StreamObserver<Object> forwardingInstance = forwardErrorsOnly(delegate); forwardingInstance.onNext(new Object()); forwardingInstance.onCompleted(); RuntimeException errorToForward = new RuntimeException("Sample exception"); forwardingInstance.onError(errorToForward); assertThat(delegate.getError()).isEqualTo(errorToForward); assertThat(delegate.responses()).isEmpty(); assertThat(delegate.isCompleted()).isFalse(); }
@Internal public static <T> StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate) { return new ErrorForwardingObserver<>(delegate); }
StreamObservers { @Internal public static <T> StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate) { return new ErrorForwardingObserver<>(delegate); } }
StreamObservers { @Internal public static <T> StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate) { return new ErrorForwardingObserver<>(delegate); } private  StreamObservers(); }
StreamObservers { @Internal public static <T> StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate) { return new ErrorForwardingObserver<>(delegate); } private  StreamObservers(); static StreamObserver<T> noOpObserver(); static void ack(StreamObserver<Response> responseObserver); @Internal static StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate); @Internal static MemoizingObserver<T> memoizingObserver(); @SuppressWarnings("ChainOfInstanceofChecks") // Only way to check an exact throwable type. static Optional<Error> fromStreamError(Throwable throwable); }
StreamObservers { @Internal public static <T> StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate) { return new ErrorForwardingObserver<>(delegate); } private  StreamObservers(); static StreamObserver<T> noOpObserver(); static void ack(StreamObserver<Response> responseObserver); @Internal static StreamObserver<T> forwardErrorsOnly(StreamObserver<?> delegate); @Internal static MemoizingObserver<T> memoizingObserver(); @SuppressWarnings("ChainOfInstanceofChecks") // Only way to check an exact throwable type. static Optional<Error> fromStreamError(Throwable throwable);  }