本文整理汇总了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());
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例15: get
import com.google.common.base.Throwables; //导入方法依赖的package包/类
@Override
public T get() {
Throwables.throwIfUnchecked(exception);
throw new RuntimeException(exception);
}