congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CancellationException
Code IndexAdd Tabnine to your IDE (free)

How to use
CancellationException
in
java.util.concurrent

Best Java code snippets using java.util.concurrent.CancellationException (Showing top 20 results out of 3,699)

Refine searchRefine arrow

  • ExecutionException
  • TimeoutException
  • TimeUnit
  • CountDownLatch
origin: apache/geode

@Override
public Object get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
 if (Thread.interrupted())
  throw new InterruptedException(); // check in case latch is null
 if (this.isCancelled) {
  throw new CancellationException(
    "Future was cancelled");
 }
 if (this.latch != null) {
  if (!this.latch.await(unit.toMillis(timeout))) {
   throw new TimeoutException();
  }
 }
 return this.value;
}
origin: google/guava

 private static CancellationException cancellationExceptionWithCause(
   @Nullable String message, @Nullable Throwable cause) {
  CancellationException exception = new CancellationException(message);
  exception.initCause(cause);
  return exception;
 }
}
origin: org.eclipse.jetty/jetty-util

@Override
public C get() throws InterruptedException, ExecutionException
{
  _latch.await();
  if (_cause==COMPLETED)
    return _result;
  if (_cause instanceof CancellationException)
    throw (CancellationException) new CancellationException().initCause(_cause);
  throw new ExecutionException(_cause);
}
origin: h2oai/h2o-2

if ((s = status) >= 0 && (ns = unit.toNanos(timeout)) > 0L) {
  long deadline = System.nanoTime() + ns;
  ForkJoinPool p = null;
        if ((ms = TimeUnit.NANOSECONDS.toMillis(ns)) > 0L &&
          U.compareAndSwapInt(this, STATUS, s, s | SIGNAL)) {
          synchronized (this) {
  Throwable ex;
  if (s == CANCELLED)
    throw new CancellationException();
  if (s != EXCEPTIONAL)
    throw new TimeoutException();
  if ((ex = getThrowableException()) != null)
    throw new ExecutionException(ex);
origin: Netflix/EVCache

boolean status = latch.await(to, unit);
  status = latch.await(to, unit);
  if (log.isDebugEnabled()) log.debug("Retry status : " + status);
  if (log.isDebugEnabled()) log.debug("Total duration due to gc event = " + (System.currentTimeMillis() - startTime) + " msec.");
    if (throwException) throw new ExecutionException(new CancellationException("Cancelled"));
    throw new ExecutionException(op.getException());
origin: wildfly/wildfly

V innerGet(long nanosTimeout) throws InterruptedException, ExecutionException, TimeoutException {
  if (!tryAcquireSharedNanos(0, nanosTimeout))
    throw new TimeoutException();
  if (getState() == CANCELLED)
    throw new CancellationException();
  if (exception != null)
    throw new ExecutionException(exception);
  return result;
}
origin: org.eclipse.jetty/jetty-util

@Override
public boolean cancel(boolean mayInterruptIfRunning)
{
  if (_done.compareAndSet(false,true))
  {
    _cause=new CancellationException();
    _latch.countDown();
    return true;
  }
  return false;
}
origin: rapidoid/rapidoid

public static void on(CountDownLatch latch, long timeout, TimeUnit unit) {
  try {
    latch.await(timeout, unit);
  } catch (InterruptedException e) {
    throw new CancellationException();
  }
}
origin: apache/ignite

  /** {@inheritDoc} */
  @Override public T get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException {
    A.ensure(timeout >= 0, "timeout >= 0");
    A.notNull(unit, "unit != null");
    try {
      T res = fut.get(unit.toMillis(timeout));
      if (fut.isCancelled())
        throw new CancellationException("Task was cancelled: " + fut);
      return res;
    }
    catch (IgniteFutureTimeoutCheckedException e) {
      TimeoutException e2 = new TimeoutException();
      e2.initCause(e);
      throw e2;
    }
    catch (ComputeTaskTimeoutCheckedException e) {
      throw new ExecutionException("Task execution timed out during waiting for task result: " + fut, e);
    }
    catch (IgniteCheckedException e) {
      // Task cancellation may cause throwing exception.
      if (fut.isCancelled()) {
        RuntimeException ex = new CancellationException("Task was cancelled: " + fut);
        ex.initCause(e);
        throw ex;
      }
      throw new ExecutionException("Failed to get task result.", e);
    }
  }
}
origin: robolectric/robolectric

public synchronized T get(long timeout, TimeUnit unit) throws InterruptedException {
 if (cancelled) {
  throw new CancellationException();
 } else {
  while (!hasRun) this.wait(unit.toMillis(timeout));
  return result;
 }
}
origin: apache/mina

/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings({ "unchecked" })
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  LOG.trace("Entering wait");
  if (!latch.await(timeout, unit)) {
    throw new TimeoutException();
  }
  LOG.trace("Wait completed");
  if (isCancelled()) {
    throw new CancellationException();
  }
  Object object = result.get();
  if (object instanceof ExecutionException) {
    throw (ExecutionException) object;
  } else {
    return (V) object;
  }
}
origin: zstackio/zstack

@Override
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  if (isCancelled()) {
    throw new CancellationException(task.getClass().getCanonicalName() + " has been cancelled");
  }
  
  doWait(unit.toMillis(timeout));
  if (exception != null) {
    throw new ExecutionException(exception);
  }
  return ret;
}
origin: killme2008/xmemcached

/**
 * {@inheritDoc}
 */
public R get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 long startTime = System.currentTimeMillis();
 long timeoutMillis = TimeUnit.MILLISECONDS.convert(timeout, unit);
 synchronized (this.sync) {
  for (;;) {
   if (this.isDone) {
    if (this.isCancelled) {
     throw new CancellationException();
    } else if (this.failure != null) {
     throw new ExecutionException(this.failure);
    } else if (this.result != null) {
     return this.result;
    }
   } else if (System.currentTimeMillis() - startTime > timeoutMillis) {
    throw new TimeoutException();
   }
   this.sync.wait(timeoutMillis);
  }
 }
}
origin: springside/springside4

private T getResult() throws ExecutionException {
  if (this.ex != null) {
    throw new ExecutionException(this.ex);
  }
  if (cancelled) {
    throw new CancellationException();
  }
  return this.result;
}
origin: apache/hbase

  LOG.debug("Scan with primary region returns " + e.getCause());
 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: apache/incubator-druid

@Test
public void testErrorCode()
{
 Assert.assertEquals(
   "Query cancelled",
   new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorCode()
 );
 Assert.assertEquals("Query cancelled", new QueryInterruptedException(new CancellationException()).getErrorCode());
 Assert.assertEquals("Query interrupted", new QueryInterruptedException(new InterruptedException()).getErrorCode());
 Assert.assertEquals("Query timeout", new QueryInterruptedException(new TimeoutException()).getErrorCode());
 Assert.assertEquals("Unknown exception", new QueryInterruptedException(null).getErrorCode());
 Assert.assertEquals("Unknown exception", new QueryInterruptedException(new ISE("Something bad!")).getErrorCode());
 Assert.assertEquals(
   "Resource limit exceeded",
   new QueryInterruptedException(new ResourceLimitExceededException("too many!")).getErrorCode()
 );
 Assert.assertEquals(
   "Unknown exception",
   new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorCode()
 );
}
origin: org.netbeans.api/org-openide-util

  @Override
  public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
    if (cancelled.get()) {
      throw new CancellationException();
    }
    long millis = TimeUnit.MILLISECONDS.convert(timeout, unit);
    t.waitFinished(millis);
    if (cancelled.get()) {
      throw new CancellationException();
    }
    return null;
  }
}
origin: google/guava

public void testImmediateFailedFuture_cancellationException() throws Exception {
 CancellationException exception = new CancellationException();
 ListenableFuture<String> future = immediateFailedFuture(exception);
 assertFalse(future.isCancelled());
 assertThat(future.toString()).endsWith("[status=FAILURE, cause=[" + exception + "]]");
 try {
  getDone(future);
  fail();
 } catch (ExecutionException expected) {
  assertSame(exception, expected.getCause());
 }
 try {
  getDoneFromTimeoutOverload(future);
  fail();
 } catch (ExecutionException expected) {
  assertSame(exception, expected.getCause());
 }
}
origin: apache/flink

  @Override
  public Object get(long timeout, @Nonnull TimeUnit unit) throws InterruptedException, TimeoutException {
    synchronized (lock) {
      while (!canceled) {
        unit.timedWait(lock, timeout);
      }
      if (canceled) {
        throw new CancellationException();
      } else {
        throw new TimeoutException();
      }
    }
  }
}
origin: google/guava

 @Override
 public void run() {
  MapMakerInternalMap<?, ?, ?, ?> map = mapReference.get();
  if (map == null) {
   throw new CancellationException();
  }
  for (Segment<?, ?, ?, ?> segment : map.segments) {
   segment.runCleanup();
  }
 }
}
java.util.concurrentCancellationException

Javadoc

Exception indicating that the result of a value-producing task, such as a FutureTask, cannot be retrieved because the task was cancelled.

Most used methods

  • <init>
    Constructs a CancellationException with the specified detail message.
  • initCause
  • getMessage
  • setStackTrace
  • getStackTrace
  • toString
  • fillInStackTrace
  • getCause
  • printStackTrace
  • getLocalizedMessage
  • getSuppressed
  • getSuppressed

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now