Java Code Examples for java.util.concurrent.CancellationException#initCause()

The following examples show how to use java.util.concurrent.CancellationException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Haltable.java    From database with GNU General Public License v2.0 6 votes vote down vote up
@Override
final public V get() throws InterruptedException, ExecutionException {
    lock.lock();
    try {
        while (!halt) {
            halted.await();
        }
        if(cancelled) {
            final CancellationException t = new CancellationException();
            t.initCause(firstCause);
            throw t;
        }
        if (error)
            throw new ExecutionException(firstCause);
        return result;
    } finally {
        lock.unlock();
    }
}
 
Example 2
Source File: FutureCallback.java    From mongodb-async-driver with Apache License 2.0 6 votes vote down vote up
/**
 * Implementation to get the future's value.
 *
 * @return The value set for the future.
 * @throws CancellationException
 *             If the future was canceled.
 * @throws ExecutionException
 *             If the future failed due to an exception.
 */
private V getValue() throws CancellationException, ExecutionException {
    final int state = getState();
    switch (state) {
    case COMPLETED:
        if (myException != null) {
            throw new ExecutionException(myException);
        }
        return myValue;

    case CANCELED:
    case INTERRUPTED:
        final CancellationException cancellation = new CancellationException(
                "Future was canceled.");
        cancellation.initCause(myException);

        throw cancellation;

    default:
        throw new IllegalStateException("Sync in invalid state: "
                + state);
    }
}
 
Example 3
Source File: AbstractFuture.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
private static CancellationException cancellationExceptionWithCause(
    @Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
}
 
Example 4
Source File: AbstractFuture.java    From letv with Apache License 2.0 4 votes vote down vote up
static final CancellationException cancellationExceptionWithCause(String message, Throwable cause) {
    CancellationException exception = new CancellationException(message);
    exception.initCause(cause);
    return exception;
}
 
Example 5
Source File: AbstractFuture.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static CancellationException cancellationExceptionWithCause(@Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
}
 
Example 6
Source File: AbstractFuture.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static CancellationException cancellationExceptionWithCause(@Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
}
 
Example 7
Source File: AbstractFuture.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static CancellationException cancellationExceptionWithCause(@Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
}
 
Example 8
Source File: AbstractFuture.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static CancellationException cancellationExceptionWithCause(@Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
}
 
Example 9
Source File: AbstractFuture.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private static CancellationException cancellationExceptionWithCause(
    @Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
}