本文整理匯總了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);
}