/** * Flattens a class's type hierarchy into a set of {@code Class} objects including all * superclasses (transitively) and all interfaces implemented by these superclasses. */ @VisibleForTesting static ImmutableSet<Class<?>> flattenHierarchy(Class<?> concreteClass) { try { return flattenHierarchyCache.getUnchecked(concreteClass); } catch (UncheckedExecutionException e) { throw Throwables.propagate(e.getCause()); } }
@Override public Type getType(TypeSignature signature) { Type type = types.get(signature); if (type == null) { try { return parametricTypeCache.getUnchecked(signature); } catch (UncheckedExecutionException e) { throwIfUnchecked(e.getCause()); throw new RuntimeException(e.getCause()); } } return type; }
/** * Flattens a class's type hierarchy into a set of {@code Class} objects including all * superclasses (transitively) and all interfaces implemented by these superclasses. */ @VisibleForTesting static ImmutableSet<Class<?>> flattenHierarchy(Class<?> concreteClass) { try { return flattenHierarchyCache.getUnchecked(concreteClass); } catch (UncheckedExecutionException e) { throw Throwables.propagate(e.getCause()); } }
private static <K, V> V get(LoadingCache<K, V> cache, K key) { try { return cache.getUnchecked(key); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
private SpecializedFunctionKey getSpecializedFunctionKey(Signature signature) { try { return specializedFunctionKeyCache.getUnchecked(signature); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
public List<File> getFiles(SchemaTableName table) { try { return cachedFiles.getUnchecked(table); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
public MongoTable getTable(SchemaTableName tableName) throws TableNotFoundException { try { return tableCache.getUnchecked(tableName); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
@Override public Principal createAuthenticatedPrincipal(String user, String password) { try { return authenticationCache.getUnchecked(new Credentials(user, password)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), AccessDeniedException.class); throw e; } }
public InternalAggregationFunction getAggregateFunctionImplementation(Signature signature) { checkArgument(signature.getKind() == AGGREGATE, "%s is not an aggregate function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature); try { return specializedAggregationCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
public ScalarFunctionImplementation getScalarFunctionImplementation(Signature signature) { checkArgument(signature.getKind() == SCALAR, "%s is not a scalar function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature); try { return specializedScalarCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
public WindowFunctionSupplier getWindowFunctionImplementation(Signature signature) { checkArgument(signature.getKind() == WINDOW || signature.getKind() == AGGREGATE, "%s is not a window function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature); try { return specializedWindowCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
public void testRunWithTimeout_badRunnableWithEnoughTime() throws Exception { try { service.runWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS); fail("no exception thrown"); } catch (UncheckedExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class); } }
public void testRunUninterruptiblyWithTimeout_badRunnableWithEnoughTime() throws Exception { try { service.runUninterruptiblyWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS); fail("no exception thrown"); } catch (UncheckedExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class); } }
public void testCallWithTimeout_wrapsUncheckedException() throws Exception { Exception exception = new RuntimeException("test"); try { timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS); fail("Expected UncheckedExecutionException"); } catch (UncheckedExecutionException e) { assertThat(e.getCause()).isEqualTo(exception); } }
public void testRunUninterruptiblyWithTimeout_wrapsUncheckedException() throws Exception { RuntimeException exception = new RuntimeException("test"); try { timeLimiter.runUninterruptiblyWithTimeout( runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS); fail("Expected UncheckedExecutionException"); } catch (UncheckedExecutionException e) { assertThat(e.getCause()).isEqualTo(exception); } }
public void testRunWithTimeout_wrapsUncheckedException() throws Exception { RuntimeException exception = new RuntimeException("test"); try { timeLimiter.runWithTimeout(runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS); fail("Expected UncheckedExecutionException"); } catch (UncheckedExecutionException e) { assertThat(e.getCause()).isEqualTo(exception); } }
@Override public Map<K, V> getAll(Iterable<? extends K> keys) { try { return cache.getAll(keys); } catch (UncheckedExecutionException e) { if (e.getCause() instanceof CacheMissException) { return ImmutableMap.of(); } throw (RuntimeException) e.getCause(); } catch (ExecutionException e) { throw new CompletionException(e); } catch (ExecutionError e) { throw (Error) e.getCause(); } }
public void testGetUnchecked_ExecutionExceptionChecked() { try { getUnchecked(FAILED_FUTURE_CHECKED_EXCEPTION); fail(); } catch (UncheckedExecutionException expected) { assertEquals(CHECKED_EXCEPTION, expected.getCause()); } }
public void testGetUnchecked_ExecutionExceptionUnchecked() { try { getUnchecked(FAILED_FUTURE_UNCHECKED_EXCEPTION); fail(); } catch (UncheckedExecutionException expected) { assertEquals(UNCHECKED_EXCEPTION, expected.getCause()); } }
public void testGetUnchecked_ExecutionExceptionOtherThrowable() { try { getUnchecked(FAILED_FUTURE_OTHER_THROWABLE); fail(); } catch (UncheckedExecutionException expected) { assertEquals(OTHER_THROWABLE, expected.getCause()); } }