Java 8 ExecutionException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ExecutionException class.

This code example shows how to use the following methods:getCause
        try { 
            return get(); 
        } catch (InterruptedException e) {
            throw new ElasticSearchInterruptedException(e.getMessage());
        } catch (ExecutionException e) {
            if (e.getCause() instanceof ElasticSearchException) {
                throw (ElasticSearchException) e.getCause();
            } else { 
                throw new TransportException("Failed execution", e);
            } 
        } 
    } 
 
    @Override 
    public V txGet(long timeout, TimeUnit unit) throws ElasticSearchException {
        try { 
            return get(timeout, unit);
        } catch (TimeoutException e) {
            throw new ElasticSearchTimeoutException(e.getMessage());
        } catch (InterruptedException e) {
8
CodeRank
This code example shows how to use the following methods:getCause
            throw rethrowExecutionException(e);
        } 
    } 
 
    static ElasticSearchException rethrowExecutionException(ExecutionException e) {
        if (e.getCause() instanceof ElasticSearchException) {
            ElasticSearchException esEx = (ElasticSearchException) e.getCause();
            Throwable root = esEx.unwrapCause();
            if (root instanceof ElasticSearchException) {
                return (ElasticSearchException) root;
            } 
            return new UncategorizedExecutionException("Failed execution", root);
        } else { 
            return new UncategorizedExecutionException("Failed execution", e);
        } 
    } 
 
    @Override 
    public void onResponse(L result) {
        set(convert(result));
8
CodeRank
This code example shows how to use the following methods:getCause
            return get(); 
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new ElasticsearchIllegalStateException("Future got interrupted", e);
        } catch (ExecutionException e) {
            if (e.getCause() instanceof ElasticsearchException) {
                throw (ElasticsearchException) e.getCause();
            } else { 
                throw new TransportException("Failed execution", e);
            } 
        } 
    } 
 
    @Override 
    public V txGet(long timeout, TimeUnit unit) throws ElasticsearchException {
        try { 
            return get(timeout, unit);
        } catch (TimeoutException e) {
            throw new ElasticsearchTimeoutException(e.getMessage());
        } catch (InterruptedException e) {
7
CodeRank
This code example shows how to use the following methods:getCause
            throw rethrowExecutionException(e);
        } 
    } 
 
    static ElasticsearchException rethrowExecutionException(ExecutionException e) {
        if (e.getCause() instanceof ElasticsearchException) {
            ElasticsearchException esEx = (ElasticsearchException) e.getCause();
            Throwable root = esEx.unwrapCause();
            if (root instanceof ElasticsearchException) {
                return (ElasticsearchException) root;
            } 
            return new UncategorizedExecutionException("Failed execution", root);
        } else { 
            return new UncategorizedExecutionException("Failed execution", e);
        } 
    } 
 
    @Override 
    public void onResponse(L result) {
        set(convert(result));
7
CodeRank
This code example shows how to use the following methods:
            } 
        } 
        if (cancelledFlag.get()) {
            throw MESSAGES.taskWasCancelled(); 
        } else if (failed != null) {
            throw new ExecutionException(failed);
        } 
        return result;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getCause
        try { 
            future.get();
            Assert.fail("ExecutionException was expected");
        } catch (ExecutionException ee) {
            // expecting this and we are able to get caused exception 
            Assert.assertNotNull(ee.getCause());
        } catch (Exception e) {
            Assert.fail("ExecutionException was expected and not " + e.getClass());
        } 
    } 
 
    /** 
     * Asynchronous inherited from parent 
     */ 
    @Test 
    public void testVoidParentAsyncMethod() throws Exception { 
        AsyncChildBean bean = lookup(AsyncChildBean.class);
        Assert.assertFalse(AsyncParentClass.voidMethodCalled);
        final CountDownLatch latch = new CountDownLatch(1);
        final CountDownLatch latch2 = new CountDownLatch(1);
7
CodeRank
This code example shows how to use the following methods:getCause
      futureCallback.get(30, TimeUnit.SECONDS);
      Assert.fail("get should have thrown exception");
    } 
    catch (ExecutionException e)
    { 
      Assert.assertTrue(e.getCause().getMessage().contains(uri.toString()));
    } 
 
  } 
 
  @Test 
  public void testHttpToRestErrorMessage() throws TimeoutException, InterruptedException, ExecutionException 
  { 
    FutureCallback<RestResponse> futureCallback = new FutureCallback<RestResponse>();
    TransportCallback<RestResponse> callback =
        new TransportCallbackAdapter<RestResponse>(futureCallback);
    TransportCallback<RestResponse> bridgeCallback = HttpBridge.httpToRestCallback(callback);
 
    RestResponse restResponse = new RestResponseBuilder().build();
 
7
CodeRank
This code example shows how to use the following methods:
 
  @Override 
  public V get() throws InterruptedException, 
      ExecutionException 
  { 
    throw new ExecutionException(_exception); 
  } 
 
  @Override 
  public V get(long arg0, TimeUnit arg1) throws InterruptedException, 
      ExecutionException, 
      TimeoutException 
  { 
    throw new ExecutionException(_exception); 
  } 
 
  @Override 
  public boolean isCancelled() 
  { 
    return false; 
6
CodeRank
This code example shows how to use the following methods:getCause
		catch (InterruptedException ex) {
			Thread.currentThread().interrupt();
			return; 
		} 
		catch (ExecutionException ex) {
			cause = ex.getCause();
			if (cause == null) {
				cause = ex;
			} 
		} 
		catch (Throwable ex) {
			cause = ex;
		} 
		this.callbacks.failure(cause);
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage, printStackTrace
            ProductSceneView sceneView = getContext().getAppContext().getSelectedProductSceneView();
            final Layer rootLayer = getContext().getLayerContext().getRootLayer();
            rootLayer.getChildren().add(sceneView.getFirstImageLayerIndex(), layer);
        } catch (InterruptedException ignored) {
        } catch (ExecutionException e) {
            getContext().showErrorDialog("Could not load shape file: \n" + e.getMessage());
            e.printStackTrace();
        } 
 
    } 
} 
6
CodeRank

Related Java 8 ExecutionException Questions & Answers:

See Code Examples for Java 8 ExecutionException Methods: