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


Java Throwables.propagate方法代碼示例

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


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

示例1: toBytes

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void toBytes(ByteBuf buf) {
	ByteArrayOutputStream obj = new ByteArrayOutputStream();

	try {
		GZIPOutputStream gzip = new GZIPOutputStream(obj);
		ObjectOutputStream objStream = new ObjectOutputStream(gzip);
		objStream.writeObject(values);
		objStream.close();
	}
	catch (IOException e) {
		Throwables.propagate(e);
	}
	buf.writeShort(obj.size());
	buf.writeBytes(obj.toByteArray());
}
 
開發者ID:p455w0rd,項目名稱:ToughExpansion,代碼行數:17,代碼來源:PacketConfigSync.java

示例2: findResource

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public InputStream findResource(URI systemId)
{
	try
	{
		String path = systemId.toString();
		if( !path.startsWith(basePath) )
		{
			path = PathUtils.filePath(basePath, path);
		}
		return fileSystemService.read(handle, path);
	}
	catch( IOException e )
	{
		throw Throwables.propagate(e);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:FileSystemResourceLocator.java

示例3: before

import com.google.common.base.Throwables; //導入方法依賴的package包/類
private void before(final AgentClusterRule clusterRule) throws IOException {
    clusterRule.before();

    AgentConfig agentConfig = clusterRule.agentConfig();
    File configFile = temporaryFolder.newFile();
    Files.writeTo(configFile, agentConfig.toJson());
    agentBootstrapThread = new Thread(() -> {
        try {
            AgentBootstrap.main(new String[]{configFile.getAbsolutePath()});
        } catch (Exception e) {
            Throwables.propagate(e);
        }
    });

    registryClusterClient = clusterRule.agentRegistryClusterClient();
}
 
開發者ID:florentw,項目名稱:bench,代碼行數:17,代碼來源:AgentBootstrapIntegrationTest.java

示例4: getSigningCredential

import com.google.common.base.Throwables; //導入方法依賴的package包/類
private Credential getSigningCredential(final RoleDescriptorResolver resolver, final RequestAbstractType profileRequest) {
    try {
        final MetadataCredentialResolver kekCredentialResolver = new MetadataCredentialResolver();
        final SignatureValidationConfiguration config = getSignatureValidationConfiguration();
        kekCredentialResolver.setRoleDescriptorResolver(resolver);
        kekCredentialResolver.setKeyInfoCredentialResolver(
                DefaultSecurityConfigurationBootstrap.buildBasicInlineKeyInfoCredentialResolver());
        kekCredentialResolver.initialize();
        final CriteriaSet criteriaSet = new CriteriaSet();
        criteriaSet.add(new SignatureValidationConfigurationCriterion(config));
        criteriaSet.add(new UsageCriterion(UsageType.SIGNING));

        buildEntityCriteriaForSigningCredential(profileRequest, criteriaSet);

        return kekCredentialResolver.resolveSingle(criteriaSet);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:20,代碼來源:SamlObjectSignatureValidator.java

示例5: toLong

import com.google.common.base.Throwables; //導入方法依賴的package包/類
/**
 * Milliseconds since 'epoch' in UTC time.
 * 
 * @return
 */
@Override
public long toLong()
{
	if( conceptualValue != null )
	{
		try
		{
			return new UtcDate(Dates.ISO_DATE_ONLY.parse(conceptualValue, DateHelper.UTC_TIMEZONE).getTime())
				.toLong();
		}
		catch( ParseException pe )
		{
			throw Throwables.propagate(pe);
		}
	}
	return utc;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:UtcDate.java

示例6: getGlobalTask

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public GlobalTaskStartInfo getGlobalTask(ClusteredTask globalTask, long millis)
{
	if( !globalTask.isGlobal() )
		throw new Error("Isn't a global task");
	String globalId = globalTask.getGlobalId();
	String existingTaskId = getRunningGlobalTask(globalId);
	if( existingTaskId != null )
	{
		ensureGlobalTaskRunner(existingTaskId, globalTask);
		return new GlobalTaskStartInfo(existingTaskId, true);
	}
	String globalPath = zookeeperService.getFullPath(ZK_GLOBALTASKPATH, globalId);
	try
	{
		String taskId = UUID.randomUUID().toString();
		try
		{
			curator.create().creatingParentsIfNeeded().forPath(globalPath, taskId.getBytes());
			return new GlobalTaskStartInfo(startInternal(globalTask, taskId), false);
		}
		catch( NodeExistsException nee )
		{
			final String taskFromZk = new String(curator.getData().forPath(globalPath));
			//ensure there *is* a task for this
			ensureGlobalTaskRunner(taskFromZk, globalTask);
			return new GlobalTaskStartInfo(taskFromZk, false);
		}
	}
	catch( Exception e )
	{
		throw Throwables.propagate(e);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:ClusteredTaskServiceImpl.java

示例7: destroy

import com.google.common.base.Throwables; //導入方法依賴的package包/類
/**
 * Stops the couchbase client.
 */
@PreDestroy
public void destroy() {
    try {
        LOGGER.debug("Shutting down Couchbase");
        this.couchbase.shutdown();
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:13,代碼來源:CouchbaseTicketRegistry.java

示例8: close

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public void close()
{
	if( response != null && !consumed )
	{
		final HttpEntity entity = response.getEntity();
		if( entity != null )
		{
			try
			{
				EntityUtils.consume(entity);
			}
			catch( IOException io )
			{
				throw Throwables.propagate(io);
			}
		}
		consumed = true;
	}

	try
	{
		Closeables.close(in, true);
	}
	catch( IOException ex )
	{
		// Ignore
	}

	if( httpMethod != null )
	{
		httpMethod.releaseConnection();
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:HttpServiceImpl.java

示例9: viewMessage

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public Pair<MessageView, List<MessageTrack>> viewMessage(String subject, final String msgId) {
    try {

        MessageExt messageExt = mqAdminExt.viewMessage(msgId);
        List<MessageTrack> messageTrackList = messageTrackDetail(messageExt);
        return new Pair<>(MessageView.fromMessageExt(messageExt), messageTrackList);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
 
開發者ID:didapinchegit,項目名稱:rocket-console,代碼行數:11,代碼來源:MessageServiceImpl.java

示例10: getBalance

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public BigDecimal getBalance(String accountAddress, Convert.Unit unit) {
    try {
        BigInteger balance = web3j.ethGetBalance(accountAddress, DefaultBlockParameterName.LATEST).send().getBalance();
        return Convert.fromWei(new BigDecimal(balance), unit);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:9,代碼來源:EthereumService.java

示例11: msgToInternalDate

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public static ZonedDateTime msgToInternalDate(ImapMessage msg) {
  try {
    return msg.getInternalDate();
  } catch (UnfetchedFieldException ex) {
    throw Throwables.propagate(ex);
  }
}
 
開發者ID:HubSpot,項目名稱:NioImapClient,代碼行數:8,代碼來源:TestUtils.java

示例12: deleteDocuments

import com.google.common.base.Throwables; //導入方法依賴的package包/類
public void deleteDocuments(Term key) {
  committerThread.throwExceptionIfAny();
  try {
    writer.deleteDocuments(key);
  } catch (IOException ex) {
    throw Throwables.propagate(ex);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:9,代碼來源:LuceneSearchIndex.java

示例13: OAIProperties

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Inject
public OAIProperties(@Named("oaiLegacyProps") Properties properties) throws Throwable // NOSONAR
{
	this.properties = new OAIExtendedProperties(properties);
	try
	{
		AbstractCatalog.factory(this.properties, null);
	}
	catch( Exception e )
	{
		Throwables.propagate(e);
	}

}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:OAIProperties.java

示例14: doQuery

import com.google.common.base.Throwables; //導入方法依賴的package包/類
private String doQuery(String query, @Nullable String sort, boolean reverse, @Nullable String where,
	@Nullable String info, int offset, int length)
{
	final Request request = createRequest("search");
	//cleanup query
	String q = query;
	q = q.replaceAll("/", "\\\\/");

	request.addParameter("q", q);
	request.addParameter("start", offset);
	request.addParameter("length", length);
	request.addParameter("reverse", Boolean.toString(reverse));
	if( sort != null )
	{
		request.addParameter("order", sort);
	}
	if( where != null )
	{
		request.addParameter("where", where);
	}
	if( info != null )
	{
		request.addParameter("info", info);
	}
	try( Response response = httpService.getWebContent(request, configService.getProxyDetails()) )
	{
		if( response.isOk() )
		{
			StringWriter sw = new StringWriter();
			CharStreams.copy(new InputStreamReader(response.getInputStream()), sw);
			return sw.toString();
		}

		throw new RuntimeException("Unable to query cloud search results: " + response.getMessage());
	}
	catch( IOException io )
	{
		throw Throwables.propagate(io);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:41,代碼來源:CloudServiceImpl.java

示例15: checkedGet

import com.google.common.base.Throwables; //導入方法依賴的package包/類
@Override
public DOMRpcResult checkedGet(final long timeout, final TimeUnit unit) throws TimeoutException, DOMRpcException {
    try {
        return get(timeout, unit);
    } catch (InterruptedException | ExecutionException e) {
        // FIXME: Add exception mapping
        throw Throwables.propagate(e);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:10,代碼來源:LazyDOMRpcResultFuture.java


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