本文整理了Java中java.util.concurrent.TimeoutException.getCause()
方法的一些代码示例,展示了TimeoutException.getCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeoutException.getCause()
方法的具体详情如下:
包路径:java.util.concurrent.TimeoutException
类名称:TimeoutException
方法名:getCause
暂无
代码示例来源:origin: jamesdbloom/mockserver
public HttpResponse sendRequest(HttpRequest httpRequest, long timeout, TimeUnit unit) {
try {
return sendRequest(httpRequest).get(timeout, unit);
} catch (TimeoutException e) {
throw new SocketCommunicationException("Response was not received from MockServer after " + ConfigurationProperties.maxSocketTimeout() + " milliseconds, to make the proxy wait longer please use \"mockserver.maxSocketTimeout\" system property or ConfigurationProperties.maxSocketTimeout(long milliseconds)", e.getCause());
} catch (InterruptedException | ExecutionException ex) {
Throwable cause = ex.getCause();
if (cause instanceof SocketConnectionException) {
throw (SocketConnectionException) cause;
} else if (cause instanceof ConnectException) {
throw new SocketConnectionException("Unable to connect to socket " + httpRequest.socketAddressFromHostHeader(), cause);
} else if (cause instanceof UnknownHostException) {
throw new SocketConnectionException("Unable to resolve host " + httpRequest.socketAddressFromHostHeader(), cause);
} else if (cause instanceof IOException) {
throw new SocketConnectionException(cause.getMessage(), cause);
} else {
throw new RuntimeException("Exception while sending request - " + ex.getMessage(), ex);
}
}
}
}
代码示例来源:origin: jamesdbloom/mockserver
public void submit(HttpForwardActionResult future, Runnable command, boolean synchronous) {
if (future != null) {
if (synchronous) {
try {
future.getHttpResponse().get(ConfigurationProperties.maxSocketTimeout(), MILLISECONDS);
} catch (TimeoutException e) {
future.getHttpResponse().setException(new SocketCommunicationException("Response was not received after " + ConfigurationProperties.maxSocketTimeout() + " milliseconds, to make the proxy wait longer please use \"mockserver.maxSocketTimeout\" system property or ConfigurationProperties.maxSocketTimeout(long milliseconds)", e.getCause()));
} catch (InterruptedException | ExecutionException ex) {
future.getHttpResponse().setException(ex);
}
command.run();
} else {
future.getHttpResponse().addListener(command, getScheduler());
}
}
}
代码示例来源:origin: apache/phoenix
private void sendHBaseMetaData(Set<TableDescriptor> tableDescriptors, boolean pollingNeeded) throws SQLException {
SQLException sqlE = null;
for (TableDescriptor descriptor : tableDescriptors) {
try {
modifyTable(descriptor.getTableName().getName(), descriptor, pollingNeeded);
} catch (IOException e) {
sqlE = ServerUtil.parseServerException(e);
} catch (InterruptedException e) {
// restore the interrupt status
Thread.currentThread().interrupt();
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.INTERRUPTED_EXCEPTION).setRootCause(e).build().buildException();
} catch (TimeoutException e) {
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.OPERATION_TIMED_OUT).setRootCause(e.getCause() != null ? e.getCause() : e).build().buildException();
} finally {
if (sqlE != null) {
throw sqlE;
}
}
}
}
private void setTransactional(byte[] physicalTableName, TableDescriptorBuilder tableDescriptorBuilder, PTableType tableType, String txValue, Map<String, Object> tableProps) throws SQLException {
代码示例来源:origin: org.glassfish.tyrus/tyrus-core
/**
* Wait for the future to be completed.
* <p>
* {@link java.util.concurrent.Future#get()} will be invoked and exception processed (if thrown).
*
* @param future to be processed.
* @throws IOException when {@link java.io.IOException} is the cause of thrown {@link java.util
* .concurrent.ExecutionException}
* it will be extracted and rethrown. Otherwise whole ExecutionException will be
* rethrown wrapped in {@link java.io.IOException}.
*/
private void processFuture(Future<?> future) throws IOException {
try {
future.get(SYNC_SEND_TIMEOUT, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
throw new IOException(e.getCause());
}
} catch (TimeoutException e) {
throw new IOException(e.getCause());
}
}
代码示例来源:origin: eclipse-ee4j/tyrus
/**
* Wait for the future to be completed.
* <p>
* {@link java.util.concurrent.Future#get()} will be invoked and exception processed (if thrown).
*
* @param future to be processed.
* @throws IOException when {@link java.io.IOException} is the cause of thrown {@link java.util
* .concurrent.ExecutionException}
* it will be extracted and rethrown. Otherwise whole ExecutionException will be
* rethrown wrapped in {@link java.io.IOException}.
*/
private void processFuture(Future<?> future) throws IOException {
try {
future.get(SYNC_SEND_TIMEOUT, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
throw new IOException(e.getCause());
}
} catch (TimeoutException e) {
throw new IOException(e.getCause());
}
}
代码示例来源:origin: org.apache.marmotta/marmotta-sparql
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
try {
sparqlService.query(QueryLanguage.SPARQL, query, output, format.getMime(), configurationService.getIntConfiguration("sparql.timeout", 60));
} catch (MarmottaException | MalformedQueryException ex) {
throw new WebApplicationException(ex.getCause(), Response.status(Response.Status.BAD_REQUEST).entity(WebServiceUtil.jsonErrorResponse(ex)).build());
} catch (TimeoutException e) {
throw new WebApplicationException(e.getCause(), Response.status(Response.Status.GATEWAY_TIMEOUT).entity(WebServiceUtil.jsonErrorResponse(e)).build());
}
}
};
代码示例来源:origin: apache/marmotta
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
try {
sparqlService.query(QueryLanguage.SPARQL, query, output, format.getMime(), configurationService.getIntConfiguration("sparql.timeout", 60));
} catch (MarmottaException | MalformedQueryException ex) {
throw new WebApplicationException(ex.getCause(), Response.status(Response.Status.BAD_REQUEST).entity(WebServiceUtil.jsonErrorResponse(ex)).build());
} catch (TimeoutException e) {
throw new WebApplicationException(e.getCause(), Response.status(Response.Status.GATEWAY_TIMEOUT).entity(WebServiceUtil.jsonErrorResponse(e)).build());
}
}
};
代码示例来源:origin: com.heroku.api/heroku-http-ning-async
@Override
public <T> T execute(Request<T> req, Map<String,String> extraHeaders, String key) {
try {
return executeAsync(req, extraHeaders, key).get(30L, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new HerokuAPIException("request interrupted", e);
} catch (ExecutionException e) {
if (e.getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause();
} else if (e.getCause() != null && e.getCause().getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause().getCause();
} else if (e.getCause().getCause() != null && e.getCause().getCause().getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause().getCause().getCause();
}
throw new HerokuAPIException("execution exception", e.getCause());
} catch (TimeoutException e) {
throw new HerokuAPIException("request timeout after 30 sec", e.getCause());
}
}
代码示例来源:origin: apache/phoenix
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.INTERRUPTED_EXCEPTION).setRootCause(e).build().buildException();
} catch (TimeoutException e) {
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.OPERATION_TIMED_OUT).setRootCause(e.getCause() != null ? e.getCause() : e).build().buildException();
} finally {
if (sqlE != null) {
代码示例来源:origin: heroku/heroku.jar
@Override
public <T> T execute(Request<T> req, Map<String,String> extraHeaders, String key) {
try {
return executeAsync(req, extraHeaders, key).get(30L, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new HerokuAPIException("request interrupted", e);
} catch (ExecutionException e) {
if (e.getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause();
} else if (e.getCause() != null && e.getCause().getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause().getCause();
} else if (e.getCause().getCause() != null && e.getCause().getCause().getCause() instanceof RequestFailedException) {
throw (RequestFailedException) e.getCause().getCause().getCause();
}
throw new HerokuAPIException("execution exception", e.getCause());
} catch (TimeoutException e) {
throw new HerokuAPIException("request timeout after 30 sec", e.getCause());
}
}
代码示例来源:origin: elder-oss/sourcerer
throw new RetriableEventWriteException("Timeout writing events", ex.getCause());
代码示例来源:origin: forcedotcom/EMP-Connector
System.err.println("Timed out subscribing");
System.exit(1);
throw e.getCause();
代码示例来源:origin: org.mock-server/mockserver-core
public HttpResponse sendRequest(HttpRequest httpRequest, long timeout, TimeUnit unit) {
try {
return sendRequest(httpRequest).get(timeout, unit);
} catch (TimeoutException e) {
throw new SocketCommunicationException("Response was not received from MockServer after " + ConfigurationProperties.maxSocketTimeout() + " milliseconds, to make the proxy wait longer please use \"mockserver.maxSocketTimeout\" system property or ConfigurationProperties.maxSocketTimeout(long milliseconds)", e.getCause());
} catch (InterruptedException | ExecutionException ex) {
Throwable cause = ex.getCause();
if (cause instanceof SocketConnectionException) {
throw (SocketConnectionException) cause;
} else if (cause instanceof ConnectException) {
throw new SocketConnectionException("Unable to connect to socket " + httpRequest.socketAddressFromHostHeader(), cause);
} else if (cause instanceof UnknownHostException) {
throw new SocketConnectionException("Unable to resolve host " + httpRequest.socketAddressFromHostHeader(), cause);
} else if (cause instanceof IOException) {
throw new SocketConnectionException(cause.getMessage(), cause);
} else {
throw new RuntimeException("Exception while sending request - " + ex.getMessage(), ex);
}
}
}
}
代码示例来源:origin: com.haulmont.yarg/yarg
connection.close();
if (tex.getCause() instanceof BootstrapException
|| tex.getCause() instanceof com.sun.star.comp.helper.BootstrapException) {
throw new OpenOfficeException("Failed to connect to open office. Please check open office path " + openOfficePath, tex);
代码示例来源:origin: org.apache.phoenix/phoenix-core
private void sendHBaseMetaData(Set<TableDescriptor> tableDescriptors, boolean pollingNeeded) throws SQLException {
SQLException sqlE = null;
for (TableDescriptor descriptor : tableDescriptors) {
try {
modifyTable(descriptor.getTableName().getName(), descriptor, pollingNeeded);
} catch (IOException e) {
sqlE = ServerUtil.parseServerException(e);
} catch (InterruptedException e) {
// restore the interrupt status
Thread.currentThread().interrupt();
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.INTERRUPTED_EXCEPTION).setRootCause(e).build().buildException();
} catch (TimeoutException e) {
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.OPERATION_TIMED_OUT).setRootCause(e.getCause() != null ? e.getCause() : e).build().buildException();
} finally {
if (sqlE != null) {
throw sqlE;
}
}
}
}
private void setTransactional(byte[] physicalTableName, TableDescriptorBuilder tableDescriptorBuilder, PTableType tableType, String txValue, Map<String, Object> tableProps) throws SQLException {
代码示例来源:origin: org.mock-server/mockserver-core
public void submit(HttpForwardActionResult future, Runnable command, boolean synchronous) {
if (future != null) {
if (synchronous) {
try {
future.getHttpResponse().get(ConfigurationProperties.maxSocketTimeout(), MILLISECONDS);
} catch (TimeoutException e) {
future.getHttpResponse().setException(new SocketCommunicationException("Response was not received after " + ConfigurationProperties.maxSocketTimeout() + " milliseconds, to make the proxy wait longer please use \"mockserver.maxSocketTimeout\" system property or ConfigurationProperties.maxSocketTimeout(long milliseconds)", e.getCause()));
} catch (InterruptedException | ExecutionException ex) {
future.getHttpResponse().setException(ex);
}
command.run();
} else {
future.getHttpResponse().addListener(command, getScheduler());
}
}
}
代码示例来源:origin: cuba-platform/yarg
connection.close();
if (tex.getCause() instanceof BootstrapException
|| tex.getCause() instanceof com.sun.star.comp.helper.BootstrapException) {
throw new OpenOfficeException("Failed to connect to open office. Please check open office path " + openOfficePath, tex);
代码示例来源:origin: co.paralleluniverse/quasar-actors
return true;
} catch (ExecutionException e) {
log().info("Child {} terminated with exception {}", child.actor, ex.getCause());
return true;
} catch (TimeoutException e) {
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
private void sendHBaseMetaData(Set<TableDescriptor> tableDescriptors, boolean pollingNeeded) throws SQLException {
SQLException sqlE = null;
for (TableDescriptor descriptor : tableDescriptors) {
try {
modifyTable(descriptor.getTableName().getName(), descriptor, pollingNeeded);
} catch (IOException e) {
sqlE = ServerUtil.parseServerException(e);
} catch (InterruptedException e) {
// restore the interrupt status
Thread.currentThread().interrupt();
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.INTERRUPTED_EXCEPTION).setRootCause(e).build().buildException();
} catch (TimeoutException e) {
sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.OPERATION_TIMED_OUT).setRootCause(e.getCause() != null ? e.getCause() : e).build().buildException();
} finally {
if (sqlE != null) {
throw sqlE;
}
}
}
}
private void setTransactional(byte[] physicalTableName, TableDescriptorBuilder tableDescriptorBuilder, PTableType tableType, String txValue, Map<String, Object> tableProps) throws SQLException {
代码示例来源:origin: com.haulmont.reports/reports-core
connection.close();
if (tex.getCause() instanceof BootstrapException) {
throw new OpenOfficeException("Failed to connect to LibreOffice. Please check LibreOffice path " + openOfficePath, tex);
内容来源于网络,如有侵权,请联系作者删除!