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); } } } }
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()); } } }
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 {
/** * 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()); } }
/** * 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()); } }
@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()); } } };
@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()); } } };
@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()); } }
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) {
@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()); } }
throw new RetriableEventWriteException("Timeout writing events", ex.getCause());
System.err.println("Timed out subscribing"); System.exit(1); throw e.getCause();
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); } } } }
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 {
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()); } } }
return true; } catch (ExecutionException e) { log().info("Child {} terminated with exception {}", child.actor, ex.getCause()); return true; } catch (TimeoutException e) {
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 {
connection.close(); if (tex.getCause() instanceof BootstrapException) { throw new OpenOfficeException("Failed to connect to LibreOffice. Please check LibreOffice path " + openOfficePath, tex);