private SessionFactory getSessionFactory() { try { return this.sessionFactoryFuture.get(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new IllegalStateException("Interrupted during initialization of Hibernate SessionFactory", ex); } catch (ExecutionException ex) { Throwable cause = ex.getCause(); if (cause instanceof HibernateException) { // Rethrow a provider configuration exception (possibly with a nested cause) directly throw (HibernateException) cause; } throw new IllegalStateException("Failed to asynchronously initialize Hibernate SessionFactory: " + ex.getMessage(), cause); } } }
@Override public EntityManagerFactory getNativeEntityManagerFactory() { if (this.nativeEntityManagerFactory != null) { return this.nativeEntityManagerFactory; } else { Assert.state(this.nativeEntityManagerFactoryFuture != null, "No native EntityManagerFactory available"); try { return this.nativeEntityManagerFactoryFuture.get(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new IllegalStateException("Interrupted during initialization of native EntityManagerFactory", ex); } catch (ExecutionException ex) { Throwable cause = ex.getCause(); if (cause instanceof PersistenceException) { // Rethrow a provider configuration exception (possibly with a nested cause) directly throw (PersistenceException) cause; } throw new IllegalStateException("Failed to asynchronously initialize native EntityManagerFactory: " + ex.getMessage(), cause); } } }
@Override public ClientHttpResponse execute() throws IOException { try { return executeAsync().get(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new IOException("Interrupted during request execution", ex); } catch (ExecutionException ex) { if (ex.getCause() instanceof IOException) { throw (IOException) ex.getCause(); } else { throw new IOException(ex.getMessage(), ex.getCause()); } } }
private DoubleGauge get(MonitorConfig config) { try { return gauges.get(config); } catch (ExecutionException e) { LOGGER.error("Failed to get a gauge for {}: {}", config, e.getMessage()); throw Throwables.propagate(e); } }
private void get(CompletableFuture future) { try { future.get(); } catch (InterruptedException e) { logger.error(e.getMessage(),e); } catch (ExecutionException e) { logger.error(e.getMessage(),e); } } private Thread start(ServerApplication next, Module module, CompletableFuture start) {
/** * Closes the input stream, and "joins" (wait for complete execution * together with potential exception thrown) of the async request. */ @Override public void close() throws IOException { // close super.close(); // "join" async request try { getLastResponse(); } catch (ExecutionException e) { throw new IOException(e.getMessage(), e.getCause()); } catch (InterruptedException e) { throw new IOException(e.getMessage(), e); } }
private void debugCheckGlyph(String fontName, char c) { if (log.isDebugEnabled()) { try { if (!GlyphCheck.hasChar(fontName, c)) { Throwable t = new Throwable(); log.debug("FIXME", t); } } catch (ExecutionException e) { log.error(e.getMessage(), e); } } }
/** * Inspects the cause of the specified {@code ExecutionException} and * creates a {@code ConcurrentRuntimeException} with the checked cause if * necessary. This method works exactly like * {@link #extractCause(ExecutionException)}. The only difference is that * the cause of the specified {@code ExecutionException} is extracted as a * runtime exception. This is an alternative for client code that does not * want to deal with checked exceptions. * * @param ex the exception to be processed * @return a {@code ConcurrentRuntimeException} with the checked cause */ public static ConcurrentRuntimeException extractCauseUnchecked( final ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentRuntimeException(ex.getMessage(), ex.getCause()); }
public SliceQuery getQuery(final InternalRelationType type, Direction dir) { CacheEntry ce; try { ce = cache.get(type.longId(),new Callable<CacheEntry>() { @Override public CacheEntry call() throws Exception { return new CacheEntry(edgeSerializer,type); } }); } catch (ExecutionException e) { throw new AssertionError("Should not happen: " + e.getMessage()); } assert ce!=null; return ce.get(dir); }
@Override public ClientHttpResponse execute() throws IOException { try { return executeAsync().get(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new IOException("Interrupted during request execution", ex); } catch (ExecutionException ex) { if (ex.getCause() instanceof IOException) { throw (IOException) ex.getCause(); } else { throw new IOException(ex.getMessage(), ex.getCause()); } } }
/** * Inspects the cause of the specified {@code ExecutionException} and * creates a {@code ConcurrentException} with the checked cause if * necessary. This method performs the following checks on the cause of the * passed in exception: * <ul> * <li>If the passed in exception is <b>null</b> or the cause is * <b>null</b>, this method returns <b>null</b>.</li> * <li>If the cause is a runtime exception, it is directly thrown.</li> * <li>If the cause is an error, it is directly thrown, too.</li> * <li>In any other case the cause is a checked exception. The method then * creates a {@link ConcurrentException}, initializes it with the cause, and * returns it.</li> * </ul> * * @param ex the exception to be processed * @return a {@code ConcurrentException} with the checked cause */ public static ConcurrentException extractCause(final ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentException(ex.getMessage(), ex.getCause()); }
static BaseServiceException translateAndThrow(ExecutionException ex) { BaseServiceException.translate(ex); throw new ComputeException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
static BaseServiceException translateAndThrow(ExecutionException ex) { BaseServiceException.translate(ex); throw new BigQueryException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
public void shutdown() { if (!zconf.isClusterMode()) { return; } running.set(false); try { if (null != raftSessionClient) { raftSessionClient.close().get(3, TimeUnit.SECONDS); } if (null != raftClient) { raftClient.close().get(3, TimeUnit.SECONDS); } } catch (InterruptedException e) { LOGGER.error(e.getMessage()); } catch (ExecutionException e) { LOGGER.error(e.getMessage()); } catch (TimeoutException e) { LOGGER.error(e.getMessage()); } }
public SliceQuery getQuery(final InternalRelationType type, Direction dir) { CacheEntry ce; try { ce = cache.get(type.longId(), () -> new CacheEntry(edgeSerializer,type)); } catch (ExecutionException e) { throw new AssertionError("Should not happen: " + e.getMessage()); } assert ce!=null; return ce.get(dir); }
private void commit(AppendEventTransaction appendEventTransaction) { try { appendEventTransaction.commit(); } catch (ExecutionException e) { throw new EventStoreException(e.getMessage(), e.getCause()); } catch (TimeoutException e) { throw new org.axonframework.messaging.ExecutionException("Timeout while executing request", e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new EventStoreException(e.getMessage(), e); } }
@Override public TrackingToken createHeadToken() { try { io.axoniq.axonserver.grpc.event.TrackingToken token = eventStoreClient.getLastToken().get(); return new GlobalSequenceTrackingToken(token.getToken()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new EventStoreException(e.getMessage(), e); } catch (ExecutionException e) { throw new EventStoreException(e.getMessage(), e); } }
@Override public Optional<Long> lastSequenceNumberFor(String aggregateIdentifier) { try { ReadHighestSequenceNrResponse lastSequenceNumber = eventStoreClient .lastSequenceNumberFor(aggregateIdentifier).get(); return lastSequenceNumber.getToSequenceNr() < 0 ? Optional.empty() : Optional.of(lastSequenceNumber.getToSequenceNr()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new EventStoreException(e.getMessage(), e); } catch (ExecutionException e) { throw new EventStoreException(e.getMessage(), e); } }
@Override public TrackingToken createTailToken() { try { io.axoniq.axonserver.grpc.event.TrackingToken token = eventStoreClient.getFirstToken().get(); if (token.getToken() < 0) { return null; } return new GlobalSequenceTrackingToken(token.getToken() - 1); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new EventStoreException(e.getMessage(), e); } catch (ExecutionException e) { throw new EventStoreException(e.getMessage(), e); } }
@Test public void testMaster() throws Exception { startDefaultMaster("--zk-cluster-id=" + zkClusterId); final HeliosClient client = defaultClient(); // This should succeed since the cluster ID was created by SystemTestBase client.jobs().get(); // Delete the cluster ID zk().curatorWithSuperAuth().delete().forPath(Paths.configId(zkClusterId)); // Call jobs again, and this time it should throw an exception because the cluster ID is gone try { client.jobs().get(); } catch (ExecutionException e) { assertThat(e.getMessage(), containsString("500")); } }