List of usage examples for com.google.common.util.concurrent UncheckedExecutionException UncheckedExecutionException
public UncheckedExecutionException(@Nullable Throwable cause)
From source file:com.sk89q.guavabackport.cache.AbstractLoadingCache.java
@Override public V getUnchecked(final K key) { try {//from w ww .j av a 2 s . co m return this.get(key); } catch (ExecutionException e) { throw new UncheckedExecutionException(e.getCause()); } }
From source file:com.isotrol.impe3.nr.api.CachingNodeRepository.java
private static RuntimeException ex(ExecutionException e) { final Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { return (RuntimeException) cause; } else {/*from ww w. j a v a 2s. c om*/ return new UncheckedExecutionException(cause); } }
From source file:org.asoem.greyfish.utils.collect.ConcurrentObjectPool.java
@Override public T borrow(final Callable<T> objectFactory) throws ExecutionException { checkNotNull(objectFactory);/*from w w w . j a v a2 s . c o m*/ @Nullable T poll = deque.poll(); if (poll == null) { try { poll = objectFactory.call(); } catch (Exception e) { throw new ExecutionException(e); } catch (Error e) { throw new ExecutionError(e); } catch (Throwable e) { throw new UncheckedExecutionException(e); } } return poll; }
From source file:com.github.benmanes.caffeine.guava.CaffeinatedGuavaLoadingCache.java
@Override @SuppressWarnings("PMD.PreserveStackTrace") public V get(K key) throws ExecutionException { requireNonNull(key);//from w w w . ja va 2 s .c o m try { return cache.get(key); } catch (InvalidCacheLoadException e) { throw e; } catch (CacheLoaderException e) { throw new ExecutionException(e.getCause()); } catch (RuntimeException e) { throw new UncheckedExecutionException(e); } catch (Error e) { throw new ExecutionError(e); } }
From source file:com.linecorp.armeria.server.grpc.interop.ArmeriaGrpcServer.java
@Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { try {/*from ww w .ja va 2s . c o m*/ shutdownFuture.get(timeout, unit); } catch (ExecutionException e) { throw new UncheckedExecutionException(e); } catch (TimeoutException e) { // Ignore. } return isTerminated; }
From source file:org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult.java
/** * // w w w . jav a 2s . co m * @param job * @return result of the job's execution * @throws ExecutionException * if the job contained an error */ public <T> T apply(AsyncCreateResponse job) { boolean completed = jobComplete.apply(job.getJobId()); logger.trace("<< job(%s) complete(%s)", job, completed); AsyncJob<T> jobWithResult = client.getAsyncJobClient().<T>getAsyncJob(job.getJobId()); checkState(completed, "job %s failed to complete in time %s", job.getJobId(), jobWithResult); if (jobWithResult.getError() != null) throw new UncheckedExecutionException(String.format("job %s failed with exception %s", job.getJobId(), jobWithResult.getError().toString())) { }; return jobWithResult.getResult(); }
From source file:org.jclouds.rest.internal.BlockOnFuture.java
private static RuntimeException propagateCause(Exception e) { Throwable cause = e.getCause(); if (cause == null) { UncheckedExecutionException unchecked = new UncheckedExecutionException(e.getMessage()) { private static final long serialVersionUID = 1L; };/*from w w w . j a va 2 s . co m*/ unchecked.setStackTrace(e.getStackTrace()); throw unchecked; } StackTraceElement[] combined = concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class); cause.setStackTrace(combined); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } if (cause instanceof Error) { throw (Error) cause; } // The cause is a weird kind of Throwable, so throw the outer exception. throw new RuntimeException(e); }
From source file:zipkin.storage.elasticsearch.LazyClient.java
@Override protected InternalElasticsearchClient compute() { InternalElasticsearchClient client = clientFactory.create(allIndices); try {/* w w w. j a v a2 s . c o m*/ String version = client.getVersion(); String versionSpecificTemplate = versionSpecificTemplate(version); client.ensureTemplate(indexTemplateName, versionSpecificTemplate); } catch (IOException e) { client.close(); throw new UncheckedExecutionException(e); } return client; }
From source file:org.asoem.greyfish.utils.collect.SynchronizedKeyedObjectPool.java
@Override public V borrow(final K key, final Callable<? extends V> valueLoader) throws ExecutionException { checkNotNull(key);//from w ww . j av a 2s. c o m checkNotNull(valueLoader); final List<V> collection = multimap.get(key); synchronized (multimap) { if (collection.isEmpty()) { try { return valueLoader.call(); } catch (Exception e) { throw new ExecutionException(e); } catch (Error e) { throw new ExecutionError(e); } catch (Throwable e) { throw new UncheckedExecutionException(e); } } else { return collection.remove(collection.size()); } } }
From source file:com.linecorp.armeria.server.grpc.interop.ArmeriaGrpcServer.java
@Override public void awaitTermination() throws InterruptedException { try {//from w w w. ja v a2 s . c o m shutdownFuture.get(); } catch (ExecutionException e) { throw new UncheckedExecutionException(e); } }