本文整理匯總了Java中com.google.common.util.concurrent.UncheckedExecutionException類的典型用法代碼示例。如果您正苦於以下問題:Java UncheckedExecutionException類的具體用法?Java UncheckedExecutionException怎麽用?Java UncheckedExecutionException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UncheckedExecutionException類屬於com.google.common.util.concurrent包,在下文中一共展示了UncheckedExecutionException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAssertionConsumerServiceUri
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
@Timed
public ResourceLocation getAssertionConsumerServiceUri(String entityId, Optional<Integer> assertionConsumerServiceIndex) {
ImmutableMap<String, String> queryParams = ImmutableMap.of();
if (assertionConsumerServiceIndex.isPresent()) {
queryParams = ImmutableMap.of(
Urls.ConfigUrls.ASSERTION_CONSUMER_SERVICE_INDEX_PARAM,
assertionConsumerServiceIndex.get().toString());
}
final URI uri = getEncodedUri(Urls.ConfigUrls.TRANSACTIONS_ASSERTION_CONSUMER_SERVICE_URI_RESOURCE, queryParams, entityId);
try {
return resourceLocation.getUnchecked(uri);
} catch (UncheckedExecutionException e) {
Throwables.throwIfUnchecked(e.getCause());
throw new RuntimeException(e.getCause());
}
}
示例2: get
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
public ReloadableSslContext get(
File trustCertificatesFile,
Optional<File> clientCertificatesFile,
Optional<File> privateKeyFile,
Optional<String> privateKeyPassword,
long sessionCacheSize,
Duration sessionTimeout,
List<String> ciphers)
{
try {
return cache.getUnchecked(new SslContextConfig(trustCertificatesFile, clientCertificatesFile, privateKeyFile, privateKeyPassword, sessionCacheSize, sessionTimeout, ciphers));
}
catch (UncheckedExecutionException | ExecutionError e) {
throw new RuntimeException("Error initializing SSL context", e.getCause());
}
}
示例3: testBulkLoadUncheckedException
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
public void testBulkLoadUncheckedException() throws ExecutionException {
Exception e = new RuntimeException();
CacheLoader<Object, Object> loader = exceptionLoader(e);
LoadingCache<Object, Object> cache = CacheBuilder.newBuilder()
.recordStats()
.build(bulkLoader(loader));
CacheStats stats = cache.stats();
assertEquals(0, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
try {
cache.getAll(asList(new Object()));
fail();
} catch (UncheckedExecutionException expected) {
assertSame(e, expected.getCause());
}
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
}
示例4: compileFilterWithNoInputColumns
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
private OperatorFactory compileFilterWithNoInputColumns(Expression filter, ExpressionCompiler compiler)
{
filter = ExpressionTreeRewriter.rewriteWith(new SymbolToInputRewriter(ImmutableMap.<Symbol, Integer>of()), filter);
IdentityHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(TEST_SESSION, metadata, SQL_PARSER, INPUT_TYPES, ImmutableList.of(filter));
try {
PageProcessor processor = compiler.compilePageProcessor(toRowExpression(filter, expressionTypes), ImmutableList.of());
return new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.<Type>of());
}
catch (Throwable e) {
if (e instanceof UncheckedExecutionException) {
e = e.getCause();
}
throw new RuntimeException("Error compiling " + filter + ": " + e.getMessage(), e);
}
}
示例5: compileFilterProject
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
private OperatorFactory compileFilterProject(Expression filter, Expression projection, ExpressionCompiler compiler)
{
filter = ExpressionTreeRewriter.rewriteWith(new SymbolToInputRewriter(INPUT_MAPPING), filter);
projection = ExpressionTreeRewriter.rewriteWith(new SymbolToInputRewriter(INPUT_MAPPING), projection);
IdentityHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(TEST_SESSION, metadata,
SQL_PARSER, INPUT_TYPES, ImmutableList.of(filter, projection));
try {
List<RowExpression> projections = ImmutableList.of(toRowExpression(projection, expressionTypes));
PageProcessor processor = compiler.compilePageProcessor(toRowExpression(filter, expressionTypes), projections);
return new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of(expressionTypes.get(projection)));
}
catch (Throwable e) {
if (e instanceof UncheckedExecutionException) {
e = e.getCause();
}
throw new RuntimeException("Error compiling " + projection + ": " + e.getMessage(), e);
}
}
示例6: executeQueryStep
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
private void executeQueryStep(List<QueryStepResult> queryResults, AbstractQueryStep currentQueryStep) {
QueryStepResult queryStepResult = this.queryStepResultCache.getIfPresent(currentQueryStep);
try {
if (queryStepResult == null) {
LOGGER.debug("Local cache miss on query step {}", currentQueryStep);
queryStepResult = this.queryStepResultCache.get(currentQueryStep, () -> queryStorageService(currentQueryStep));
} else {
LOGGER.debug("Local cache hit on query step {}", currentQueryStep);
}
} catch (ExecutionException | UncheckedExecutionException e) {
LOGGER.error("Query step {} failed", currentQueryStep, e);
queryStepResult = new QueryStepResultBuilder()
.setFailedStep(true)
.setQueryStep(currentQueryStep)
.setErrorMessage(e.getMessage())
.setEngineQueryResult(ImmutableBilingualQueryResult.EMPTY_QUERY_RESULT)
.build();
}
if (queryStepResult != null && queryStepResult.isFailedStep()) {
this.queryStepResultCache.invalidate(currentQueryStep);
}
queryResults.add(queryStepResult);
}
示例7: handleHBaseException
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
public static void handleHBaseException(
Throwable t,
Iterator<Record> records,
ErrorRecordHandler errorRecordHandler
) throws StageException {
Throwable cause = t;
// Drill down to root cause
while((cause instanceof UncheckedExecutionException || cause instanceof UndeclaredThrowableException ||
cause instanceof ExecutionException) && cause.getCause() != null) {
cause = cause.getCause();
}
// Column is null or No such Column Family exception
if(cause instanceof NullPointerException || cause instanceof NoSuchColumnFamilyException) {
while(records.hasNext()) {
Record record = records.next();
errorRecordHandler.onError(new OnRecordErrorException(record, Errors.HBASE_37, cause));
}
} else {
LOG.error(Errors.HBASE_36.getMessage(), cause.toString(), cause);
throw new StageException(Errors.HBASE_36, cause.toString(), cause);
}
}
示例8: testGet_runtimeException
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
public void testGet_runtimeException() {
final RuntimeException e = new RuntimeException();
LoadingCache<Object, Object> map = CacheBuilder.newBuilder()
.maximumSize(0)
.removalListener(listener)
.build(exceptionLoader(e));
try {
map.getUnchecked(new Object());
fail();
} catch (UncheckedExecutionException uee) {
assertSame(e, uee.getCause());
}
assertTrue(listener.isEmpty());
checkEmpty(map);
}
示例9: unwrap
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
public static Throwable unwrap(@Nonnull Throwable t) {
int counter = 0;
Throwable result = t;
while (result instanceof RemoteTransportException ||
result instanceof UncheckedExecutionException ||
result instanceof UncategorizedExecutionException ||
result instanceof ExecutionException) {
Throwable cause = result.getCause();
if (cause == null) {
return result;
}
if (cause == result) {
return result;
}
if (counter > 10) {
return result;
}
counter++;
result = cause;
}
return result;
}
示例10: scanAndLoadDictionaries
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
/**
* Scans the hunspell directory and loads all found dictionaries
*/
private void scanAndLoadDictionaries() throws IOException {
if (Files.isDirectory(hunspellDir)) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(hunspellDir)) {
for (Path file : stream) {
if (Files.isDirectory(file)) {
try (DirectoryStream<Path> inner = Files.newDirectoryStream(hunspellDir.resolve(file), "*.dic")) {
if (inner.iterator().hasNext()) { // just making sure it's indeed a dictionary dir
try {
dictionaries.getUnchecked(file.getFileName().toString());
} catch (UncheckedExecutionException e) {
// The cache loader throws unchecked exception (see #loadDictionary()),
// here we simply report the exception and continue loading the dictionaries
logger.error("exception while loading dictionary {}", file.getFileName(), e);
}
}
}
}
}
}
}
}
示例11: getSetByDescriptor
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
/**
* Return a LabelSet based on the supplied descriptor.
*/
protected GrammaticalLabelSet getSetByDescriptor(GrammaticalLabelSetDescriptor desc) {
try {
HumanLanguage fallbackLang = desc.getLanguage().getFallbackLanguage();
if (fallbackLang != null) {
// Always load english first. Note, the cache never includes fallback.
GrammaticalLabelSet fallback = getSetByDescriptor(desc.getForOtherLanguage(fallbackLang));
return new GrammaticalLabelSetFallbackImpl(cache.get(desc), fallback);
} else {
return cache.get(desc); // English only!
}
}
catch(UncheckedExecutionException | ExecutionException e) {
Throwables.propagateIfPossible(e);
throw new RuntimeException("Unable to load label set for " + desc, e);
}
}
示例12: getConnection
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
public Connection getConnection(HBaseConnectionKey key) {
checkNotNull(key);
try {
Connection conn = connectionCache.get(key);
if (!isValid(conn)) {
key.lock(); // invalidate the connection with a per storage plugin lock
try {
conn = connectionCache.get(key);
if (!isValid(conn)) {
connectionCache.invalidate(key);
conn = connectionCache.get(key);
}
} finally {
key.unlock();
}
}
return conn;
} catch (ExecutionException | UncheckedExecutionException e) {
throw UserException.dataReadError(e.getCause()).build(logger);
}
}
示例13: get
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
OnDemandShardState get() throws Exception {
if (shardActor == null) {
return OnDemandShardState.newBuilder().build();
}
try {
return ONDEMAND_SHARD_STATE_CACHE.get(shardName, this::retrieveState);
} catch (ExecutionException | UncheckedExecutionException | ExecutionError e) {
if (e.getCause() != null) {
Throwables.propagateIfPossible(e.getCause(), Exception.class);
throw new RuntimeException("unexpected", e.getCause());
}
throw e;
}
}
示例14: testAuthenticateWithUnknownIssuer
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
@Test
public void testAuthenticateWithUnknownIssuer() {
Authenticator authenticator = createAuthenticator(Clock.SYSTEM, ISSUER, null);
String authToken = TestUtils.generateAuthToken(
Optional.<Collection<String>>of(AUDIENCES), Optional.of(EMAIL),
Optional.of("https://unknown.issuer.com"), Optional.of(SUBJECT),
RSA_JSON_WEB_KEY);
when(httpRequest.getHeader(HttpHeaders.AUTHORIZATION)).thenReturn("Bearer " + authToken);
try {
authenticator.authenticate(httpRequest, authInfo, SERVICE_NAME);
fail();
} catch (UncheckedExecutionException exception) {
Throwable rootCause = ExceptionUtils.getRootCause(exception);
assertTrue(rootCause instanceof UnauthenticatedException);
assertTrue(rootCause.getMessage().contains("the issuer is unknown"));
}
}
示例15: resolvePath
import com.google.common.util.concurrent.UncheckedExecutionException; //導入依賴的package包/類
static MCRFilesystemNode resolvePath(MCRPath path) throws IOException {
try {
String ifsid = nodeCache.getUnchecked(path);
MCRFilesystemNode node = MCRFilesystemNode.getNode(ifsid);
if (node != null) {
return node;
}
nodeCache.invalidate(path);
return resolvePath(path);
} catch (UncheckedExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof NoSuchFileException) {
throw (NoSuchFileException) cause;
}
if (cause instanceof NotDirectoryException) {
throw (NotDirectoryException) cause;
}
if (cause instanceof IOException) {
throw (IOException) cause;
}
throw e;
}
}