context.getResultSender().lastResult(str1.toString()); } catch (CancellationException e) { logger.info("Starting RebalanceFunction CancellationException: ", e.getMessage(), e); context.getResultSender().lastResult("CancellationException1 " + e.getMessage()); } catch (InterruptedException e) { logger.info("Starting RebalanceFunction InterruptedException: {}", e.getMessage(), e);
info("First timeout task is cancelled: " + e.getMessage()); info("Second timeout task is cancelled: " + e.getMessage());
throw new InterruptedIOException(e.getMessage()); } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage()); RpcRetryingCallerWithReadReplicas.throwEnrichedException(e, retries); } catch (CancellationException e) { throw new InterruptedIOException(e.getMessage()); } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage());
} catch (CancellationException e) { sendError(R.string.update_cancelled); Logger.warning(e.getClass().getName() + ": " + e.getMessage()); } catch (NoSuchAlgorithmException | RuntimeException | ChildManager.ChildDiedException | ChildManager.ChildNotStartedException | InterruptedException | IOException e) { sendError(R.string.error_occured);
throw new InterruptedIOException(e.getMessage()); } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage()); RpcRetryingCallerWithReadReplicas.throwEnrichedException(e, retries); } catch (CancellationException e) { throw new InterruptedIOException(e.getMessage()); } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage());
@Override public void afterExecute(Runnable r, Throwable t) { try { super.afterExecute(r, t); if (t == null && r instanceof Future<?>) { try { ((Future<?>) r).get(); } catch (CancellationException ce) { LOG.error("Thread returned a CancellationException with message " + ce.getMessage(), ce); } catch (ExecutionException ee) { t = ee.getCause(); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); // ignore/reset } } if (t != null) { LOG.error("Worker thread terminated with unhandled throwable, terminating service", t); throwableHandler.run(); } } finally { tasks.remove(r); } }
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms with uploadId %s", part, key, container, System.currentTimeMillis() - start, uploadId)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with uploadId: %s running since %dms", e.getMessage(), part, offset, size, container, uploadId, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with uploadId: %s running since %dms", e.getMessage(), part, offset, size, container, uploadId, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, ioExecutor);
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms with uploadId %s", part, key, container, System.currentTimeMillis() - start, uploadId)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with uploadId: %s running since %dms", e.getMessage(), part, offset, size, container, uploadId, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with uploadId: %s running since %dms", e.getMessage(), part, offset, size, container, uploadId, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, ioExecutor);
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms", part, key, container, System.currentTimeMillis() - start)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, ioExecutor);
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms", part, key, container, System.currentTimeMillis() - start)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, executor);
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms", part, key, container, System.currentTimeMillis() - start)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, ioExecutor);
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms", part, key, container, System.currentTimeMillis() - start)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s running since %dms", e.getMessage(), part, offset, size, container, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, ioExecutor);
@Override public void run() { try { etags.put(part, futureETag.get()); logger.debug(String.format("async uploaded part %s of %s to container %s in %sms with uploadId %s", part, key, container, System.currentTimeMillis() - start, uploadId)); } catch (CancellationException e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with uploadId: %s running since %dms", e.getMessage(), part, offset, size, container, uploadId, System.currentTimeMillis() - start); logger.debug(message); } catch (Exception e) { errorMap.put(part, e); String message = String.format("%s while uploading part %s - [%s,%s] to container %s with uploadId: %s running since %dms", e.getMessage(), part, offset, size, container, uploadId, System.currentTimeMillis() - start); logger.error(message, e); if (errors.incrementAndGet() <= maxRetries) toRetry.add(new Part(part, offset, size)); } finally { activeParts.remove(part); // remove part from the bounded-queue without blocking futureParts.remove(part); latch.countDown(); } } }, ioExecutor);
@Override protected void done() { try { get(); } catch (InterruptedException e) { Log.e(TAG, e.getMessage()); worker.abort(); postCancel(worker); e.printStackTrace(); } catch (ExecutionException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); throw new RuntimeException("An error occured while executing doInBackground()", e.getCause()); } catch (CancellationException e) { worker.abort(); postCancel(worker); Log.e(TAG, e.getMessage()); e.printStackTrace(); } } };
/** * Given a future which is holding an Either<GeneralError, T>, block on result and return an Either<GeneralError,T>. * All expected exceptions are caught and returns as GeneralError inside an Either */ public <T> Either<GeneralError, T> getEitherSafely(String label, ListenableFuture<Either<GeneralError, T>> future, long timeoutMillis) { try { return future.get(timeoutMillis, TimeUnit.MILLISECONDS); } catch (CancellationException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s request cancelled : %s", label, e.getMessage()), e); } catch (TimeoutException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s request timeout : %s", label, e.getMessage()), e); } catch (ExecutionException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s execution failed : %s", label, e.getMessage()), e); } catch (InterruptedException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s execution interrupted : %s", label, e.getMessage()), e); } }
/** * Given a future which is holding an Either<GeneralError, T>, block on result and return an Either<GeneralError,T>. * All expected exceptions are caught and returns as GeneralError inside an Either */ public <T> Either<GeneralError, T> getEitherSafely(String label, ListenableFuture<Either<GeneralError, T>> future, long timeoutMillis) { try { return future.get(timeoutMillis, TimeUnit.MILLISECONDS); } catch (CancellationException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s request cancelled : %s", label, e.getMessage()), e); } catch (TimeoutException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s request timeout : %s", label, e.getMessage()), e); } catch (ExecutionException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s execution failed : %s", label, e.getMessage()), e); } catch (InterruptedException e) { return GeneralError .<T>either("getEitherSafely", String.format("%s execution interrupted : %s", label, e.getMessage()), e); } }
/** * @see javax.swing.SwingWorker#done() */ @Override protected void done() { try { Map<SignatureType, SignatureFileInfo> updatedFiles = get(); progressDialog.setVisible(false); DialogUtils.showUpdateSuccessfulDialog(parent, updatedFiles); } catch (InterruptedException e) { log.debug(e.getMessage(), e); } catch (ExecutionException e) { log.error(e.getCause().toString(), e); progressDialog.setVisible(false); DialogUtils.showSignatureUpdateErrorDialog(parent, e.getCause()); } catch (CancellationException e) { log.warn(e.getMessage()); } finally { progressDialog.setVisible(false); progressDialog.dispose(); parent.setCursor(Cursor.getDefaultCursor()); } }
/** * @see javax.swing.SwingWorker#done() */ @Override protected void done() { try { signatureFileInfos = get(); } catch (ExecutionException e) { error = true; if (progressDialog != null) { progressDialog.setVisible(false); } log.warn(e.getCause()); DialogUtils.showSignatureUpdateErrorDialog(parent, e.getCause()); } catch (InterruptedException e) { log.debug(e); } catch (CancellationException e) { log.warn(e.getMessage()); } finally { if (progressDialog != null) { progressDialog.setVisible(false); progressDialog.dispose(); } if (parent != null) { parent.setCursor(Cursor.getDefaultCursor()); } } }
/** * @see javax.swing.SwingWorker#done() */ @Override protected void done() { try { Map<SignatureType, SignatureFileInfo> updatedFiles = get(); progressDialog.setVisible(false); DialogUtils.showUpdateSuccessfulDialog(parent, updatedFiles); } catch (InterruptedException e) { log.debug(e); } catch (ExecutionException e) { log.error(e.getCause(), e); progressDialog.setVisible(false); DialogUtils.showSignatureUpdateErrorDialog(parent, e.getCause()); } catch (CancellationException e) { log.warn(e.getMessage()); } finally { progressDialog.setVisible(false); progressDialog.dispose(); parent.setCursor(Cursor.getDefaultCursor()); } }
private static void verifyCancelationExceptionMessageOnGet(String msg, ListenableFuture<?> lf) throws InterruptedException { try { lf.get(); fail("Exception should have thrown"); } catch (ExecutionException e) { assertEquals(msg, e.getCause().getMessage()); } catch (CancellationException e) { assertEquals(msg, e.getMessage()); } }