tech.ydb.core.utils.FutureTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-core Show documentation
Show all versions of ydb-sdk-core Show documentation
Core module of Java SDK for YDB
package tech.ydb.core.utils;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
/**
*
* @author Aleksandr Gorshenin
*/
public class FutureTools {
private FutureTools() { }
public static Throwable unwrapCompletionException(Throwable throwable) {
Throwable cause = throwable;
while (cause instanceof CompletionException && cause.getCause() != null) {
cause = cause.getCause();
}
return cause;
}
public static CompletableFuture failedFuture(Throwable t) {
CompletableFuture f = new CompletableFuture<>();
f.completeExceptionally(t);
return f;
}
}