當前位置: 首頁>>代碼示例>>Java>>正文


Java Throwables.throwIfUnchecked方法代碼示例

本文整理匯總了Java中com.google.common.base.Throwables.throwIfUnchecked方法的典型用法代碼示例。如果您正苦於以下問題:Java Throwables.throwIfUnchecked方法的具體用法?Java Throwables.throwIfUnchecked怎麽用?Java Throwables.throwIfUnchecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.base.Throwables的用法示例。


在下文中一共展示了Throwables.throwIfUnchecked方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAssertionConsumerServiceUri

import com.google.common.base.Throwables; //導入方法依賴的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());
    }
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:19,代碼來源:TransactionsConfigProxy.java

示例2: createLocalHistory

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public final ClientLocalHistory createLocalHistory() {
    final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(getIdentifier(),
        nextHistoryId.getAndIncrement());

    final long stamp = lock.readLock();
    try {
        if (aborted != null) {
            Throwables.throwIfUnchecked(aborted);
            throw new RuntimeException(aborted);
        }

        final ClientLocalHistory history = new ClientLocalHistory(this, historyId);
        LOG.debug("{}: creating a new local history {}", persistenceId(), history);

        Verify.verify(histories.put(historyId, history) == null);
        return history;
    } finally {
        lock.unlockRead(stamp);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:22,代碼來源:AbstractDataStoreClientBehavior.java

示例3: createProducer

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Nonnull
@Override
public DOMDataTreeProducer createProducer(@Nonnull final Collection<DOMDataTreeIdentifier> subtrees) {
    LOG.debug("{} - Creating producer for {}", memberName, subtrees);
    final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees);

    final Object response = distributedConfigDatastore.getActorContext()
            .executeOperation(shardedDataTreeActor, new ProducerCreated(subtrees));
    if (response == null) {
        LOG.debug("{} - Received success from remote nodes, creating producer:{}", memberName, subtrees);
        return new ProxyProducer(producer, subtrees, shardedDataTreeActor,
                distributedConfigDatastore.getActorContext(), shards);
    }

    closeProducer(producer);

    if (response instanceof Throwable) {
        Throwables.throwIfUnchecked((Throwable) response);
        throw new RuntimeException((Throwable) response);
    }
    throw new RuntimeException("Unexpected response to create producer received." + response);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:23,代碼來源:DistributedShardedDOMDataTree.java

示例4: get

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public T get() {
    try {
        return delegate.call();
    } catch (Exception e) {
        // try to propagate the exception
        Throwables.throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:11,代碼來源:Delegates.java

示例5: getEncryptionCertificate

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Timed
public CertificateDto getEncryptionCertificate(String entityId) {
    URI uri = UriBuilder
            .fromUri(configUri)
            .path(Urls.ConfigUrls.ENCRYPTION_CERTIFICATES_RESOURCE)
            .buildFromEncoded(StringEncoding.urlEncode(entityId));
    try {
        return encryptionCertificates.getUnchecked(uri);
    } catch (UncheckedExecutionException e){
        Throwables.throwIfUnchecked(e.getCause());
        throw new RuntimeException(e.getCause());
    }
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:14,代碼來源:CertificatesConfigProxy.java

示例6: getSignatureVerificationCertificates

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Timed
public Collection<CertificateDto> getSignatureVerificationCertificates(String entityId) {
    URI uri = UriBuilder
            .fromUri(configUri)
            .path(Urls.ConfigUrls.SIGNATURE_VERIFICATION_CERTIFICATES_RESOURCE)
            .buildFromEncoded(StringEncoding.urlEncode(entityId));
    try {
        return signingCertificates.getUnchecked(uri);
    } catch (UncheckedExecutionException e){
        Throwables.throwIfUnchecked(e.getCause());
        throw new RuntimeException(e.getCause());
    }
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:14,代碼來源:CertificatesConfigProxy.java

示例7: getShouldHubSignResponseMessages

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public Boolean getShouldHubSignResponseMessages(String entityId) {
    final UriBuilder uriBuilder = UriBuilder
            .fromUri(configUri)
            .path(Urls.ConfigUrls.SHOULD_HUB_SIGN_RESPONSE_MESSAGES_RESOURCE);
    for (Map.Entry<String, String> entry : ImmutableMap.<String, String>of().entrySet()) {
        uriBuilder.queryParam(entry.getKey(), entry.getValue());
    }
    URI uri = uriBuilder.buildFromEncoded(StringEncoding.urlEncode(entityId).replace("+", "%20"));
    try {
        return booleanCache.getUnchecked(uri);
    } catch (UncheckedExecutionException e) {
        Throwables.throwIfUnchecked(e.getCause());
        throw new RuntimeException(e.getCause());
    }
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:16,代碼來源:TransactionsConfigProxy.java

示例8: getShouldHubUseLegacySamlStandard

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public Boolean getShouldHubUseLegacySamlStandard(String entityId) {
    final UriBuilder uriBuilder = UriBuilder
            .fromUri(configUri)
            .path(Urls.ConfigUrls.SHOULD_HUB_USE_LEGACY_SAML_STANDARD_RESOURCE);
    for (Map.Entry<String, String> entry : ImmutableMap.<String, String>of().entrySet()) {
        uriBuilder.queryParam(entry.getKey(), entry.getValue());
    }
    URI uri = uriBuilder.buildFromEncoded(StringEncoding.urlEncode(entityId).replace("+", "%20"));
    try {
        return booleanCache.getUnchecked(uri);
    } catch (UncheckedExecutionException e) {
        Throwables.throwIfUnchecked(e.getCause());
        throw new RuntimeException(e.getCause());
    }
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:16,代碼來源:TransactionsConfigProxy.java

示例9: creationTimeMillis

import com.google.common.base.Throwables; //導入方法依賴的package包/類
/**
 * Returns the creation time of this {@link Repository}.
 */
default long creationTimeMillis() {
    try {
        final List<Commit> history = history(Revision.INIT, Revision.INIT, ALL_PATH, 1).join();
        return history.get(0).when();
    } catch (CompletionException e) {
        final Throwable cause = Throwables.getRootCause(e);
        Throwables.throwIfUnchecked(cause);
        throw new StorageException("failed to retrieve the initial commit", cause);
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:14,代碼來源:Repository.java

示例10: author

import com.google.common.base.Throwables; //導入方法依賴的package包/類
/**
 * Returns the author who created this {@link Repository}.
 */
default Author author() {
    try {
        final List<Commit> history = history(Revision.INIT, Revision.INIT, ALL_PATH, 1).join();
        return history.get(0).author();
    } catch (CompletionException e) {
        final Throwable cause = Throwables.getRootCause(e);
        Throwables.throwIfUnchecked(cause);
        throw new StorageException("failed to retrieve the initial commit", cause);
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:14,代碼來源:Repository.java

示例11: CachingRepository

import com.google.common.base.Throwables; //導入方法依賴的package包/類
CachingRepository(Repository repo, RepositoryCache cache) {
    this.repo = requireNonNull(repo, "repo");
    this.cache = requireNonNull(cache, "cache").cache;

    try {
        final List<Commit> history = repo.history(Revision.INIT, Revision.INIT, ALL_PATH, 1).join();
        firstCommit = history.get(0);
    } catch (CompletionException e) {
        final Throwable cause = Throwables.getRootCause(e);
        Throwables.throwIfUnchecked(cause);
        throw new StorageException("failed to retrieve the initial commit", cause);
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:14,代碼來源:CachingRepository.java

示例12: msaMetadata

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public static String msaMetadata() {
    EntityDescriptor entityDescriptor = new EntityDescriptorFactory().idpEntityDescriptor(MSA_ENTITY_ID);
    try {
        return new MetadataFactory().metadata(anEntitiesDescriptor()
                .withEntityDescriptors(ImmutableList.of(entityDescriptor))
                .withValidUntil(DateTime.now().plusWeeks(2)).build());
    } catch (MarshallingException | SignatureException e) {
        Throwables.throwIfUnchecked(e);
        throw new RuntimeException(e);
    }

}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:13,代碼來源:MockMsaServer.java

示例13: assertNoneMatching

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@SuppressWarnings("checkstyle:IllegalCatch")
public static <T> void assertNoneMatching(final ActorRef actor, final Class<T> clazz, final long timeout) {
    Exception lastEx = null;
    int count = (int) (timeout / 50);
    for (int i = 0; i < count; i++) {
        try {
            T message = getFirstMatching(actor, clazz);
            if (message != null) {
                Assert.fail("Unexpected message received" +  message.toString());
                return;
            }

            lastEx = null;
        } catch (Exception e) {
            lastEx = e;
        }

        Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
    }

    if (lastEx != null) {
        Throwables.throwIfUnchecked(lastEx);
        throw new RuntimeException(lastEx);
    }

    return;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:28,代碼來源:MessageCollectorActor.java

示例14: getState

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@SuppressWarnings("checkstyle:IllegalCatch")
private OnDemandShardState getState() {
    try {
        return stateCache.get();
    } catch (Exception e) {
        Throwables.throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:10,代碼來源:ShardDataTreeListenerInfoMXBeanImpl.java

示例15: get

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public T get() {
	Throwables.throwIfUnchecked(exception);
	throw new RuntimeException(exception);
}
 
開發者ID:tfiskgul,項目名稱:mux2fs,代碼行數:6,代碼來源:ExceptionTranslator.java


注:本文中的com.google.common.base.Throwables.throwIfUnchecked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。