@Test public void testAsyncHandleNullResponse() throws Exception { rpcFuture.handleResponse(null); verify(rpcCallback).fail(throwableCaptor.capture()); Throwable t = throwableCaptor.getValue(); assertThat(t, instanceOf(RpcException.class)); verify(interceptor).handleResponse(null); }
public void handleResponse(Response response) { handleConnection(response); if (isAsync() && CollectionUtils.isNotEmpty(interceptors)) { int length = interceptors.size(); for (int i = length - 1; i >= 0; i--) { interceptors.get(i).handleResponse(response); } } if (isAsync()) { setRpcContext(); if (response == null) { callback.fail(new RpcException(RpcException.SERVICE_EXCEPTION, "internal error")); } else if (response.getResult() != null) { callback.success((T) response.getResult()); } else { callback.fail(response.getException()); } } }
RpcFuture implements AsyncAwareFuture<T> { public void handleResponse(Response response) { handleConnection(response); if (isAsync() && CollectionUtils.isNotEmpty(interceptors)) { int length = interceptors.size(); for (int i = length - 1; i >= 0; i--) { interceptors.get(i).handleResponse(response); } } if (isAsync()) { setRpcContext(); if (response == null) { callback.fail(new RpcException(RpcException.SERVICE_EXCEPTION, "internal error")); } else if (response.getResult() != null) { callback.success((T) response.getResult()); } else { callback.fail(response.getException()); } } } }
RpcFuture implements AsyncAwareFuture<T> { public void handleResponse(Response response) { handleConnection(response); if (isAsync() && CollectionUtils.isNotEmpty(interceptors)) { int length = interceptors.size(); for (int i = length - 1; i >= 0; i--) { interceptors.get(i).handleResponse(response); } } if (isAsync()) { setRpcContext(); if (response == null) { callback.fail(new RpcException(RpcException.SERVICE_EXCEPTION, "internal error")); } else if (response.getResult() != null) { callback.success((T) response.getResult()); } else { callback.fail(response.getException()); } } } RpcFuture();  RpcFuture(long correlationId); }
RpcFuture implements AsyncAwareFuture<T> { public void handleResponse(Response response) { handleConnection(response); if (isAsync() && CollectionUtils.isNotEmpty(interceptors)) { int length = interceptors.size(); for (int i = length - 1; i >= 0; i--) { interceptors.get(i).handleResponse(response); } } if (isAsync()) { setRpcContext(); if (response == null) { callback.fail(new RpcException(RpcException.SERVICE_EXCEPTION, "internal error")); } else if (response.getResult() != null) { callback.success((T) response.getResult()); } else { callback.fail(response.getException()); } } } RpcFuture();  RpcFuture(long correlationId); static RpcFuture createRpcFuture(Request request); void init(Timeout timeout,
                     RpcMethodInfo rpcMethodInfo,
                     RpcCallback<T> callback,
                     ChannelInfo channelInfo); void handleConnection(Response response); void handleResponse(Response response); @Override boolean isAsync(); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override T get(); @Override T get(long timeout, TimeUnit unit); @Override String toString(); }
RpcFuture implements AsyncAwareFuture<T> { public void handleResponse(Response response) { handleConnection(response); if (isAsync() && CollectionUtils.isNotEmpty(interceptors)) { int length = interceptors.size(); for (int i = length - 1; i >= 0; i--) { interceptors.get(i).handleResponse(response); } } if (isAsync()) { setRpcContext(); if (response == null) { callback.fail(new RpcException(RpcException.SERVICE_EXCEPTION, "internal error")); } else if (response.getResult() != null) { callback.success((T) response.getResult()); } else { callback.fail(response.getException()); } } } RpcFuture();  RpcFuture(long correlationId); static RpcFuture createRpcFuture(Request request); void init(Timeout timeout,
                     RpcMethodInfo rpcMethodInfo,
                     RpcCallback<T> callback,
                     ChannelInfo channelInfo); void handleConnection(Response response); void handleResponse(Response response); @Override boolean isAsync(); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override T get(); @Override T get(long timeout, TimeUnit unit); @Override String toString();  }