java.util.concurrent.CancellationException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(14.4k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中java.util.concurrent.CancellationException.getMessage()方法的一些代码示例,展示了CancellationException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CancellationException.getMessage()方法的具体详情如下:
包路径:java.util.concurrent.CancellationException
类名称:CancellationException
方法名:getMessage

CancellationException.getMessage介绍

暂无

代码示例

代码示例来源:origin: apache/geode

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);

代码示例来源:origin: apache/ignite

info("First timeout task is cancelled: " + e.getMessage());
info("Second timeout task is cancelled: " + e.getMessage());

代码示例来源:origin: apache/hbase

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());

代码示例来源:origin: cSploit/android

} 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);

代码示例来源:origin: org.apache.hbase/hbase-client

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());

代码示例来源:origin: com.github.workerframework/worker-core

@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);
  }
}

代码示例来源:origin: org.jclouds.provider/aws-s3

@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);

代码示例来源:origin: jclouds/legacy-jclouds

@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);

代码示例来源:origin: jclouds/legacy-jclouds

@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);

代码示例来源:origin: org.apache.jclouds.api/swift

@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);

代码示例来源:origin: io.cloudsoft.jclouds.api/swift

@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);

代码示例来源:origin: org.jclouds.api/swift

@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);

代码示例来源:origin: io.cloudsoft.jclouds.provider/aws-s3

@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);

代码示例来源:origin: huijimuhe/Luban-Circle-Demo

@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();
    }
  }
};

代码示例来源:origin: com.yahoo.maha/maha-par-request

/**
 * 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);
  }
}

代码示例来源:origin: com.yahoo.maha/maha-par-request-2

/**
 * 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);
  }
}

代码示例来源:origin: digital-preservation/droid

/**
 * @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());
  }
}

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

/**
 * @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());
    }
  }
}

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

/**
 * @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());
  }
}

代码示例来源:origin: threadly/threadly

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());
 }
}

相关文章