@Override public void onThrowable(Throwable t) { if (decoratedAsyncHandler != null) { decoratedAsyncHandler.onThrowable(t); } else { logger.debug("", t); } }
@Override public void cancelled() { final AsyncHandler ah = asyncHandler; if (ah != null) { try { ah.onThrowable(new CancellationException()); } catch (Throwable ignore) { } } runListeners(); }
@Override public void onThrowable(Throwable t) { try { asyncHandler.onThrowable(t); } finally { complete(); } }
public void abort(Throwable t) { exception.set(t); if (innerFuture != null) { innerFuture.cancel(true); } if (!timedOut.get() && !cancelled.get()) { try { asyncHandler.onThrowable(t); } catch (Throwable te) { logger.debug("asyncHandler.onThrowable", te); } } runListeners(); }
public final void abort(final Throwable t) { exEx.compareAndSet(null, new ExecutionException(t)); if (terminateAndExit()) return; if (onThrowableCalled.compareAndSet(false, true)) { try { asyncHandler.onThrowable(t); } catch (Throwable te) { LOGGER.debug("asyncHandler.onThrowable", te); } } latch.countDown(); runListeners(); }
public boolean cancel(boolean mayInterruptIfRunning) { if (!cancelled.get() && innerFuture != null) { urlConnection.disconnect(); try { asyncHandler.onThrowable(new CancellationException()); } catch (Throwable te) { logger.debug("asyncHandler.onThrowable", te); } cancelled.set(true); runListeners(); return innerFuture.cancel(mayInterruptIfRunning); } else { runListeners(); return false; } }
@Override public <T> ListenableFuture<T> execute(Request request, final AsyncHandler<T> asyncHandler) { try { return requestSender.sendRequest(request, asyncHandler, null, false); } catch (Exception e) { asyncHandler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e); } }
public <T> ListenableFuture<T> execute(Request request, AsyncHandler<T> handler) { try { return execute(request, handler, null); } catch (IOException e) { handler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e); } }
private V getContent() throws ExecutionException { if (isCancelled()) throw new CancellationException(); ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }
@Override public void failed(final Throwable t) { final AsyncHandler ah = asyncHandler; if (ah != null) { try { ah.onThrowable(t); } catch (Throwable ignore) { } } final HttpTransactionContext tx = transactionCtx; if (tx != null) { tx.closeConnection(); } runListeners(); }
@Override public boolean cancel(boolean force) { cancelTimeouts(); if (isCancelled.getAndSet(true)) return false; // cancel could happen before channel was attached if (channel != null) { Channels.setDiscard(channel); Channels.silentlyCloseChannel(channel); } if (!onThrowableCalled.getAndSet(true)) { try { asyncHandler.onThrowable(new CancellationException()); } catch (Throwable t) { LOGGER.warn("cancel", t); } } latch.countDown(); runListeners(); return true; }
} else { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.warn("doConnect.writeRequest()", t);
asyncHandler.onThrowable(e); return new ListenableFuture.CompletedFailure<>(e);
@Override protected void onHttpContentParsed(final HttpContent content, final FilterChainContext ctx) { final HttpTransactionContext context = HttpTransactionContext.currentTransaction(content.getHttpHeader()); final AsyncHandler handler = context.getAsyncHandler(); if (handler != null && context.currentState != AsyncHandler.STATE.ABORT) { try { context.currentState = handler.onBodyPartReceived( new GrizzlyResponseBodyPart(content, ctx.getConnection())); } catch (Exception e) { handler.onThrowable(e); } } }
@Override public void onThrowable(Throwable t) { try { proxy.onThrowable(t); } finally { //TODO log //scope.close(); } }
/** * Execute an HTTP request. * * @param request {@link Request} * @param handler an instance of {@link AsyncHandler} * @param <T> Type of the value that will be returned by the associated {@link java.util.concurrent.Future} * @return a {@link Future} of type T */ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> handler) { if (config.getRequestFilters().isEmpty()) { return httpProvider.execute(request, handler); } else { FilterContext<T> fc = new FilterContext.FilterContextBuilder<T>().asyncHandler(handler).request(request).build(); try { fc = preProcessRequest(fc); } catch (Exception e) { handler.onThrowable(e); return new ListenableFuture.CompletedFailure<T>("preProcessRequest failed", e); } return httpProvider.execute(fc.getRequest(), fc.getAsyncHandler()); } }
@Override public void onThrowable(Throwable t) { if (decoratedAsyncHandler != null) { decoratedAsyncHandler.onThrowable(t); } else { logger.debug("", t); } }
@Override public void onThrowable(Throwable t) { if (decoratedAsyncHandler != null) { decoratedAsyncHandler.onThrowable(t); } else { logger.debug("", t); } }
logger.error(t2.getMessage(), t2); asyncHandler.onThrowable(t); } finally { if (terminate) {
@Override public void onThrowable(Throwable t) { try { asyncHandler.onThrowable(t); } finally { complete(); } }