List of usage examples for com.google.common.util.concurrent UncheckedExecutionException getCause
public synchronized Throwable getCause()
From source file:org.gradle.internal.instantiation.DefaultInstantiatorFactory.java
@Override public InstantiationScheme injectScheme(Collection<Class<? extends Annotation>> injectAnnotations) { try {/*from w w w.j a v a 2 s .c o m*/ return schemes.getUnchecked(ImmutableSet.copyOf(injectAnnotations)); } catch (UncheckedExecutionException e) { throw UncheckedException.throwAsUncheckedException(e.getCause()); } }
From source file:org.apache.accumulo.core.clientImpl.MultiTableBatchWriterImpl.java
/** * Returns the table ID for the given table name. * * @param tableName/*from w w w.j av a 2s.c om*/ * The name of the table which to find the ID for * @return The table ID, or null if the table name doesn't exist */ private TableId getId(String tableName) throws TableNotFoundException { try { return Tables.getTableId(context, tableName); } catch (UncheckedExecutionException e) { Throwable cause = e.getCause(); log.error("Unexpected exception when fetching table id for {}", tableName); if (cause == null) { throw new RuntimeException(e); } else if (cause instanceof TableNotFoundException) { throw (TableNotFoundException) cause; } else if (cause instanceof TableOfflineException) { throw (TableOfflineException) cause; } throw e; } }
From source file:com.gradleware.tooling.toolingmodel.repository.internal.BaseModelRepository.java
private <U> U getFromCache(Class<?> cacheKey, Callable<U> cacheValueLoader) { try {/* w ww . j ava 2 s . c o m*/ @SuppressWarnings("unchecked") U result = (U) this.cache.get(cacheKey, cacheValueLoader); return result; } catch (UncheckedExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else { throw new RuntimeException(cause); } } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else { throw new RuntimeException(cause); } } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
From source file:com.hjz.cache.adapt.GuavaCache.java
public <T> T get(Object key, final Callable<T> valueLoader) { try {//from w w w . j a va 2s . com return (T) this.fromStoreValue(this.cache.get(key, new Callable() { public Object call() throws Exception { return GuavaCache.this.toStoreValue(valueLoader.call()); } })); } catch (ExecutionException var4) { throw new ValueRetrievalException(key, valueLoader, var4.getCause()); } catch (UncheckedExecutionException var5) { throw new ValueRetrievalException(key, valueLoader, var5.getCause()); } }
From source file:com.hortonworks.registries.schemaregistry.cache.SchemaBranchCache.java
public SchemaBranch get(Key key) throws SchemaBranchNotFoundException { SchemaBranch schemaBranch;//from w w w .j a v a 2 s .c o m try { schemaBranch = loadingCache.get(key); } catch (UncheckedExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof SchemaBranchNotFoundException) { throw (SchemaBranchNotFoundException) cause; } else { throw new RuntimeException(e); } } catch (ExecutionException e) { LOG.error("Error occurred while retrieving schema branch for [{}]", key, e); throw new RuntimeException(e); } return schemaBranch; }
From source file:io.confluent.kafka.connect.syslog.source.HostnameResolverImpl.java
@Override public InetSocketAddress resolve(SocketAddress socketAddress) { Preconditions.checkNotNull(socketAddress, "socketAddress should not be null."); Preconditions.checkState(socketAddress instanceof InetSocketAddress, "socketAddress should be InetSocketAddress."); final InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; try {//from www.ja v a 2 s .c o m return reverseDnsCache.get(inetSocketAddress.getAddress(), new Callable<InetSocketAddress>() { @Override public InetSocketAddress call() throws Exception { String hostname = inetSocketAddress.getHostName(); if (inetSocketAddress.isUnresolved()) { throw new IllegalStateException( String.format("Could not resolve %s", inetSocketAddress.getAddress())); } if (log.isDebugEnabled()) { log.debug("Resolved {} to {}. Caching result", inetSocketAddress.getAddress(), hostname); } return inetSocketAddress; } }); } catch (UncheckedExecutionException ex) { if (log.isDebugEnabled()) { log.debug("Could not resolve {}.", inetSocketAddress.getAddress(), ex.getCause()); } return inetSocketAddress; } catch (ExecutionException e) { if (log.isWarnEnabled()) { log.warn("Exception thrown while resolving ip for {}", inetSocketAddress.getAddress(), e); } return inetSocketAddress; } }
From source file:org.gradle.cache.internal.InMemoryDecoratedCache.java
@Override public V get(final K key) { Object value;// w w w . j a v a 2 s . c o m try { value = inMemoryCache.get(key, new Callable<Object>() { @Override public Object call() throws Exception { Object out = delegate.get(key); return out == null ? NULL : out; } }); } catch (UncheckedExecutionException e) { throw UncheckedException.throwAsUncheckedException(e.getCause()); } catch (ExecutionException e) { throw UncheckedException.throwAsUncheckedException(e.getCause()); } if (value == NULL) { return null; } else { return Cast.uncheckedCast(value); } }
From source file:io.prestosql.plugin.password.LdapAuthenticator.java
@Override public Principal createAuthenticatedPrincipal(String user, String password) { try {/* ww w . j a v a 2s.c om*/ return authenticationCache.getUnchecked(new Credentials(user, password)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), AccessDeniedException.class); throw e; } }
From source file:org.gradle.cache.internal.InMemoryDecoratedCache.java
@Override public V get(final K key, final Transformer<? extends V, ? super K> producer, final Runnable completion) { final AtomicReference<Runnable> completionRef = new AtomicReference<Runnable>(completion); Object value;/*w w w .j a va 2 s .c o m*/ try { value = inMemoryCache.getIfPresent(key); final boolean wasNull = value == NULL; if (wasNull) { inMemoryCache.invalidate(key); } else if (value != null) { return Cast.uncheckedCast(value); } value = inMemoryCache.get(key, new Callable<Object>() { @Override public Object call() throws Exception { if (!wasNull) { Object out = delegate.get(key); if (out != null) { return out; } } V value = producer.transform(key); delegate.putLater(key, value, completion); completionRef.set(Runnables.doNothing()); return value; } }); } catch (UncheckedExecutionException e) { throw UncheckedException.throwAsUncheckedException(e.getCause()); } catch (ExecutionException e) { throw UncheckedException.throwAsUncheckedException(e.getCause()); } finally { completionRef.get().run(); } if (value == NULL) { return null; } else { return Cast.uncheckedCast(value); } }
From source file:org.apache.gobblin.config.common.impl.InMemoryTopology.java
public Collection<ConfigKeyPath> getImportedBy(ConfigKeyPath configKey, Optional<Config> runtimeConfig) { if (this.fullImportedByMap != null) { return this.fullImportedByMap.get(configKey); }// ww w . j a v a2 s. co m try { return this.ownImportedByMap.get(configKey, () -> this.fallback.getImportedBy(configKey, runtimeConfig)); } catch (UncheckedExecutionException exc) { if (exc.getCause() instanceof UnsupportedOperationException) { computeImportedByMap(runtimeConfig); return getImportedBy(configKey, runtimeConfig); } else { throw new RuntimeException(exc); } } catch (ExecutionException ee) { throw new RuntimeException(ee); } }