@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { Future<Object> future = executor.submit(() -> { try { return method.invoke(delegate, args); } catch (InvocationTargetException e) { Throwables.rewrapAndThrowIfInstance(e.getCause(), Exception.class); Throwables.rewrapAndThrowIfInstance(e.getCause(), Error.class); throw Throwables.rewrapAndThrowUncheckedException(e.getCause()); } }); try { return future.get(); } catch (ExecutionException e) { throw Throwables.rewrap(e.getCause()); } catch (InterruptedException e) { throw new PalantirInterruptedException(e); } finally { future.cancel(cancel.equals(CancelDelegate.CANCEL)); } }
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { Future<Object> future = executor.submit(() -> { try { return method.invoke(delegate, args); } catch (InvocationTargetException e) { Throwables.rewrapAndThrowIfInstance(e.getCause(), Exception.class); Throwables.rewrapAndThrowIfInstance(e.getCause(), Error.class); throw Throwables.rewrapAndThrowUncheckedException(e.getCause()); } }); try { return future.get(); } catch (ExecutionException e) { throw Throwables.rewrap(e.getCause()); } catch (InterruptedException e) { throw new PalantirInterruptedException(e); } finally { future.cancel(cancel.equals(CancelDelegate.CANCEL)); } }