Java Code Examples for java.util.concurrent.ExecutionException#getMessage()
The following examples show how to use
java.util.concurrent.ExecutionException#getMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GaePendingResult.java From google-maps-services-java with Apache License 2.0 | 6 votes |
@Override public T await() throws ApiException, IOException, InterruptedException { try { HTTPResponse result = call.get(); metrics.endNetwork(); return parseResponse(this, result); } catch (ExecutionException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { // According to // https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/urlfetch/URLFetchService // all exceptions should be subclass of IOException so this should not happen. throw new UnknownErrorException("Unexpected exception from " + e.getMessage()); } } }
Example 2
Source File: WebAPI.java From Web-API with MIT License | 6 votes |
public static void runOnMain(Runnable runnable) throws WebApplicationException { if (Sponge.getServer().isMainThread()) { runnable.run(); } else { CompletableFuture future = CompletableFuture.runAsync(runnable, WebAPI.syncExecutor); try { future.get(); } catch (InterruptedException ignored) { } catch (ExecutionException e) { // Rethrow any web application exceptions we get, because they're handled by the servlets if (e.getCause() instanceof WebApplicationException) throw (WebApplicationException)e.getCause(); e.printStackTrace(); WebAPI.sentryCapture(e); throw new InternalServerErrorException(e.getMessage()); } } }
Example 3
Source File: RelationQueryCache.java From grakn with GNU Affero General Public License v3.0 | 5 votes |
public SliceQuery getQuery(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()); } return ce.get(dir); }
Example 4
Source File: GlobalSearchController.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Handles an error while searching. * * @param e * the exception */ private void handleSearchError(ExecutionException e) { String message = null; Throwable cause = e.getCause(); if (cause instanceof ParseException) { message = cause.getMessage() != null ? cause.getMessage() : cause.toString(); } else if (cause == null) { message = e.getMessage(); } model.clearAllCategories(); model.setError(message); }
Example 5
Source File: FileSystem.java From xenon with Apache License 2.0 | 5 votes |
/** * Cancel a copy operation. Afterwards, the copy is forgotten and subsequent queries with this copy string will lead to {@link NoSuchCopyException} * * @param copyIdentifier * the identifier of the copy operation which to cancel. * * @return a {@link CopyStatus} containing the status of the copy. * * @throws NoSuchCopyException * If the copy is not known. * @throws NotConnectedException * If file system is closed. * @throws XenonException * if an I/O error occurred. * @throws IllegalArgumentException * If the copyIdentifier is null. */ public synchronized CopyStatus cancel(String copyIdentifier) throws XenonException { if (copyIdentifier == null) { throw new IllegalArgumentException("Copy identifier may not be null"); } PendingCopy copy = pendingCopies.remove(copyIdentifier); if (copy == null) { throw new NoSuchCopyException(getAdaptorName(), "Copy not found: " + copyIdentifier); } copy.callback.cancel(); copy.future.cancel(true); XenonException ex = null; String state = "DONE"; try { copy.future.get(); } catch (ExecutionException ee) { ex = new XenonException(getAdaptorName(), ee.getMessage(), ee); state = "FAILED"; } catch (CancellationException ce) { ex = new CopyCancelledException(getAdaptorName(), "Copy cancelled by user"); state = "FAILED"; } catch (InterruptedException e) { ex = new CopyCancelledException(getAdaptorName(), "Copy interrupted by user"); state = "FAILED"; Thread.currentThread().interrupt(); } return new CopyStatusImplementation(copyIdentifier, state, copy.callback.getBytesToCopy(), copy.callback.getBytesCopied(), ex); }
Example 6
Source File: RepositoryName.java From bazel with Apache License 2.0 | 5 votes |
/** * Creates a RepositoryName from a known-valid string (not @-prefixed). Generally this is a * directory that has been created via getSourceRoot() or getPathUnderExecRoot(). */ public static RepositoryName createFromValidStrippedName(String name) { try { return repositoryNameCache.get("@" + name); } catch (ExecutionException e) { throw new IllegalArgumentException(e.getMessage()); } }
Example 7
Source File: GuavaCache.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public ValueWrapper get(Object key) { if (this.cache instanceof LoadingCache) { try { Object value = ((LoadingCache<Object, Object>) this.cache).get(key); return toValueWrapper(value); } catch (ExecutionException ex) { throw new UncheckedExecutionException(ex.getMessage(), ex); } } return super.get(key); }
Example 8
Source File: KafkaOperations.java From kafka-webview with MIT License | 5 votes |
/** * Handle ExecutionException errors when raised. * @param executionException The exception raised. * @return Appropriate exception instance to throw. */ private RuntimeException handleExecutionException(final ExecutionException executionException) { if (executionException.getCause() != null && executionException.getCause() instanceof RuntimeException) { return (RuntimeException) executionException.getCause(); } return new RuntimeException(executionException.getMessage(), executionException); }
Example 9
Source File: DefaultCompletableAsyncCompletion.java From cava with Apache License 2.0 | 5 votes |
@Override public void join(long timeout, TimeUnit unit) throws CompletionException, TimeoutException, InterruptedException { requireNonNull(unit); try { future.get(timeout, unit); } catch (ExecutionException ex) { throw new CompletionException(ex.getMessage(), ex.getCause()); } }
Example 10
Source File: DefaultCompletableAsyncResult.java From cava with Apache License 2.0 | 5 votes |
@Override @Nullable public T get(long timeout, TimeUnit unit) throws CompletionException, TimeoutException, InterruptedException { requireNonNull(unit); try { return future.get(timeout, unit); } catch (ExecutionException ex) { throw new CompletionException(ex.getMessage(), ex.getCause()); } }
Example 11
Source File: DefaultCompletableAsyncCompletion.java From incubator-tuweni with Apache License 2.0 | 5 votes |
@Override public void join(long timeout, TimeUnit unit) throws CompletionException, TimeoutException, InterruptedException { requireNonNull(unit); try { future.get(timeout, unit); } catch (ExecutionException ex) { throw new CompletionException(ex.getMessage(), ex.getCause()); } }
Example 12
Source File: DefaultCompletableAsyncResult.java From incubator-tuweni with Apache License 2.0 | 5 votes |
@Override @Nullable public T get(long timeout, TimeUnit unit) throws CompletionException, TimeoutException, InterruptedException { requireNonNull(unit); try { return future.get(timeout, unit); } catch (ExecutionException ex) { throw new CompletionException(ex.getMessage(), ex.getCause()); } }
Example 13
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public Map<Dependency, ArtifactVersions> lookupDependenciesUpdates( Set<Dependency> dependencies, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException { // Create the request for details collection for parallel lookup... final List<Callable<DependencyArtifactVersions>> requestsForDetails = new ArrayList<Callable<DependencyArtifactVersions>>( dependencies.size() ); for ( final Dependency dependency : dependencies ) { requestsForDetails.add( new DependencyLookup( dependency, usePluginRepositories ) ); } final Map<Dependency, ArtifactVersions> dependencyUpdates = new TreeMap<Dependency, ArtifactVersions>( new DependencyComparator() ); // Lookup details in parallel... final ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try { final List<Future<DependencyArtifactVersions>> responseForDetails = executor.invokeAll( requestsForDetails ); // Construct the final results... for ( final Future<DependencyArtifactVersions> details : responseForDetails ) { final DependencyArtifactVersions dav = details.get(); dependencyUpdates.put( dav.getDependency(), dav.getArtifactVersions() ); } } catch ( final ExecutionException ee ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for dependencies " + dependencies + ": " + ee.getMessage(), ee ); } catch ( final InterruptedException ie ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for dependencies " + dependencies + ": " + ie.getMessage(), ie ); } finally { executor.shutdownNow(); } return dependencyUpdates; }
Example 14
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public Map<Plugin, PluginUpdatesDetails> lookupPluginsUpdates( Set<Plugin> plugins, boolean allowSnapshots ) throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException { // Create the request for details collection for parallel lookup... final List<Callable<PluginPluginUpdatesDetails>> requestsForDetails = new ArrayList<Callable<PluginPluginUpdatesDetails>>( plugins.size() ); for ( final Plugin plugin : plugins ) { requestsForDetails.add( new PluginLookup( plugin, allowSnapshots ) ); } final Map<Plugin, PluginUpdatesDetails> pluginUpdates = new TreeMap<Plugin, PluginUpdatesDetails>( new PluginComparator() ); // Lookup details in parallel... final ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try { final List<Future<PluginPluginUpdatesDetails>> responseForDetails = executor.invokeAll( requestsForDetails ); // Construct the final results... for ( final Future<PluginPluginUpdatesDetails> details : responseForDetails ) { final PluginPluginUpdatesDetails pud = details.get(); pluginUpdates.put( pud.getPlugin(), pud.getPluginUpdatesDetails() ); } } catch ( final ExecutionException ee ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " + ee.getMessage(), ee ); } catch ( final InterruptedException ie ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " + ie.getMessage(), ie ); } finally { executor.shutdownNow(); } return pluginUpdates; }
Example 15
Source File: ConcurrentUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * 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( ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentRuntimeException(ex.getMessage(), ex.getCause()); }
Example 16
Source File: ConcurrentUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * 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( ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentRuntimeException(ex.getMessage(), ex.getCause()); }
Example 17
Source File: ConcurrentUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * 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(ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentException(ex.getMessage(), ex.getCause()); }
Example 18
Source File: ConcurrentUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * 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(ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentException(ex.getMessage(), ex.getCause()); }
Example 19
Source File: ConcurrentUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * 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(ExecutionException ex) { if (ex == null || ex.getCause() == null) { return null; } throwCause(ex); return new ConcurrentException(ex.getMessage(), ex.getCause()); }
Example 20
Source File: ConcurrentUtils.java From astor with GNU General Public License v2.0 | 3 votes |
/** * 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()); }