Package java.util.concurrent

Examples of java.util.concurrent.ExecutionException


    private V getValue() throws CancellationException, ExecutionException {
      int state = getState();
      switch (state) {
        case COMPLETED:
          if (exception != null) {
            throw new ExecutionException(exception);
          } else {
            return value;
          }

        case CANCELLED:
View Full Code Here


    // loop.

    try {
      // Record exceptions so that if we fail to obtain any
      // result, we can throw the last exception we got.
      ExecutionException ee = null;
      long lastTime = timed ? System.nanoTime() : 0;
      Iterator<? extends Callable<T>> it = tasks.iterator();

      // Start one task for sure; the rest incrementally
      futures.add(ecs.submit(it.next()));
      --ntasks;
      int active = 1;

      for (;;) {
        Future<T> f = ecs.poll();
        if (f == null) {
          if (ntasks > 0) {
            --ntasks;
            futures.add(ecs.submit(it.next()));
            ++active;
          } else if (active == 0) {
            break;
          } else if (timed) {
            f = ecs.poll(nanos, TimeUnit.NANOSECONDS);
            if (f == null) {
              throw new TimeoutException();
            }
            long now = System.nanoTime();
            nanos -= now - lastTime;
            lastTime = now;
          } else {
            f = ecs.take();
          }
        }
        if (f != null) {
          --active;
          try {
            return f.get();
          } catch (ExecutionException eex) {
            ee = eex;
          } catch (RuntimeException rex) {
            ee = new ExecutionException(rex);
          }
        }
      }

      if (ee == null) {
        ee = new ExecutionException(null);
      }
      throw ee;
    } finally {
      for (Future<T> f : futures) {
        f.cancel(true);
View Full Code Here

      private O applyTransformation(I input) throws ExecutionException {
        try {
          return function.apply(input);
        } catch (Throwable t) {
          throw new ExecutionException(t);
        }
      }
    };
  }
View Full Code Here

        synchronized (lock) {
          if (!set) {
            try {
              value = function.apply(raw);
            } catch (RuntimeException e) {
              exception = new ExecutionException(e);
            } catch (Error e) {
              exception = new ExecutionException(e);
            }
            set = true;
          }

          if (exception != null) {
View Full Code Here

      V value;
      try {
        value = computingFunction.apply(key);
      } catch (Throwable t) {
        setValueReference(new ComputationExceptionReference<K, V>(t));
        throw new ExecutionException(t);
      }

      setValueReference(new ComputedReference<K, V>(value));
      return value;
    }
View Full Code Here

      this.e = e;
    }

    @Override
    public V get() throws ExecutionException {
      throw new ExecutionException(e);
    }
View Full Code Here

        statsCounter.recordCreateException(end - start);
        throw new UncheckedExecutionException(e);
      } catch (Exception e) {
        long end = System.nanoTime();
        statsCounter.recordCreateException(end - start);
        throw new ExecutionException(e);
      } catch (Error e) {
        long end = System.nanoTime();
        statsCounter.recordCreateException(end - start);
        throw new ExecutionError(e);
      } finally {
View Full Code Here

      // Shutdown server
      this.getAdaptors()[0].invoke(this.name, SHUTDOWN_METHOD, null, null);

      // Get result of long request
      // This request should succeed since it initiated before server shutdown
      ExecutionException exception = null;
      try
      {
         Assert.assertEquals(200, future.get().intValue());
      }
      catch (ExecutionException e)
View Full Code Here

   */
  public IHttpResponse get() throws InterruptedException, ExecutionException {
      try {
          return getResponse();
      } catch (IOException ioe) {
          throw new ExecutionException(ioe.toString(), ioe);
      }
  }
View Full Code Here

      try {
            return getResponse(timeout, unit);
        } catch (SocketTimeoutException stoe) {
            throw new TimeoutException(stoe.toString());
        } catch (IOException ioe) {
            throw new ExecutionException(ioe.toString(), ioe);
        }
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.ExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.