com.networknt.eventuate.test.util.AsyncUtil Maven / Gradle / Ivy
package com.networknt.eventuate.test.util;
import com.networknt.eventuate.common.CompletableFutureUtil;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class AsyncUtil {
public static T await(CompletableFuture future) {
try {
return future.get(30, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
Throwable unwrapped = CompletableFutureUtil.unwrap(e);
if (unwrapped instanceof RuntimeException)
throw (RuntimeException)unwrapped;
else
throw new RuntimeException(unwrapped);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy