@Test public void exceptionInStart() { final Exception error = new Exception("emulated error"); ClientInterceptor interceptor = new ClientInterceptor() { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) { ClientCall<ReqT, RespT> call = next.newCall(method, callOptions); return new CheckedForwardingClientCall<ReqT, RespT>(call) { @Override protected void checkedStart(ClientCall.Listener<RespT> responseListener, Metadata headers) throws Exception { throw error; } }; } }; Channel intercepted = ClientInterceptors.intercept(channel, interceptor); @SuppressWarnings("unchecked") ClientCall.Listener<Void> listener = mock(ClientCall.Listener.class); ClientCall<Void, Void> interceptedCall = intercepted.newCall(method, CallOptions.DEFAULT); assertNotSame(call, interceptedCall); interceptedCall.start(listener, new Metadata()); interceptedCall.sendMessage(null ); interceptedCall.halfClose(); interceptedCall.request(1); call.done = true; ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class); verify(listener).onClose(captor.capture(), any(Metadata.class)); assertSame(error, captor.getValue().getCause()); ClientCall<?, ?> noop = ((CheckedForwardingClientCall<?, ?>)interceptedCall).delegate(); noop.cancel("Cancel for test", null); noop.start(null, null); noop.request(-1); noop.halfClose(); noop.sendMessage(null); assertFalse(noop.isReady()); }
public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); static Channel interceptForward(Channel channel, ClientInterceptor... interceptors); static Channel interceptForward(Channel channel,
                                         List<? extends ClientInterceptor> interceptors); static Channel intercept(Channel channel, ClientInterceptor... interceptors); static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); static Channel interceptForward(Channel channel, ClientInterceptor... interceptors); static Channel interceptForward(Channel channel,
                                         List<? extends ClientInterceptor> interceptors); static Channel intercept(Channel channel, ClientInterceptor... interceptors); static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors);  }