private Object handleThrowable(AsyncResponseImpl asyncResponse, Throwable t) { //TODO: if it is a Cancelation exception => asyncResponse.cancel(); asyncResponse.resume(t); return null; } }
private Object handleThrowable(AsyncResponseImpl asyncResponse, Throwable t) { //TODO: if it is a Cancelation exception => asyncResponse.cancel(); asyncResponse.resume(t); return null; } }
protected Object handleThrowable(AsyncResponseImpl asyncResponse, Throwable t) { if (t instanceof CancellationException) { asyncResponse.cancel(); } else { asyncResponse.resume(t); } return null; }
protected Object handleThrowable(AsyncResponseImpl asyncResponse, Throwable t) { if (t instanceof CancellationException) { asyncResponse.cancel(); } else { asyncResponse.resume(t); } return null; }
protected AsyncResponseImpl handleObservable(Message inMessage, Observable<?> obs) { final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage); Disposable d = obs.subscribe(v -> asyncResponse.resume(v), t -> handleThrowable(asyncResponse, t)); if (d == null) { throw new IllegalStateException("Subscribe did not return a Disposable"); } return asyncResponse; }
protected AsyncResponseImpl checkFutureResponse(Message inMessage, Object result) { if (result instanceof Observable) { final Observable<?> obs = (Observable<?>)result; final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage); obs.subscribe(v -> asyncResponse.resume(v), t -> handleThrowable(asyncResponse, t)); return asyncResponse; } return null; }
protected AsyncResponseImpl checkFutureResponse(Message inMessage, Object result) { if (result instanceof Observable) { final Observable<?> obs = (Observable<?>)result; final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage); obs.subscribe(v -> asyncResponse.resume(v), t -> handleThrowable(asyncResponse, t)); return asyncResponse; } return null; }
protected AsyncResponseImpl checkFutureResponse(Message inMessage, Object result) { if (result instanceof CompletionStage) { final CompletionStage<?> stage = (CompletionStage<?>)result; final AsyncResponseImpl asyncResponse = new AsyncResponseImpl(inMessage); stage.whenComplete((v, t) -> { if (t instanceof CancellationException) { asyncResponse.cancel(); } else { asyncResponse.resume(v != null ? v : t); } }); return asyncResponse; } return null; }