VFutures { public static <T> T sync(Future<T> future) throws VException { try { return future.get(); } catch (ExecutionException e) { if (e.getCause() instanceof VException) { throw (VException) e.getCause(); } else if (e.getCause() instanceof CancellationException) { throw new CanceledException(null); } else if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } throw new RuntimeException( "Vanadium futures may only raise a VException or a RuntimeException.", e.getCause()); } catch (InterruptedException e) { throw new RuntimeException("Vanadium future may not raise an InterruptedException.", e); } catch (CancellationException e) { throw new CanceledException(null); } }  static T sync(Future<T> future); static T sync(Future<T> future, long timeout, TimeUnit unit); static ListenableFuture<T> onExecutor(
            final VContext context, final ListenableFuture<T> future); static ListenableFuture<T> withUserLandChecks(
            final VContext context, final ListenableFuture<T> future);  }
@Test(expected = NoServersException.class) public void testNoServers() throws Exception { final FortuneClient client = FortuneClientFactory.getFortuneClient("/127.0.0.1"); final VContext timeout = ctx.withTimeout(Duration.millis(100)); sync(client.get(timeout)); }
@Test public void testTimeout() throws Exception { final CountDownLatch callLatch = new CountDownLatch(1); final FortuneServer server = new FortuneServerImpl(callLatch, null); final VContext serverContext = V.withNewServer(ctx, "", server, null); final FortuneClient client = FortuneClientFactory.getFortuneClient( "/" + V23TestUtil.getServerEndpoint(serverContext)); final VContext timeout = ctx.withTimeout(Duration.millis(100)); try { sync(client.get(timeout)); } catch (TimeoutException | CanceledException e) { } }