public static Throwable cause(Throwable ex) {
        if (ex instanceof ExecutionException) {
            if (ex.getCause() != null) {
                return cause(ex.getCause());
            } else {
                return ex;
            }
        } else if (ex instanceof CompletionException) {
            if (ex.getCause() != null) {
                return cause(ex.getCause());
            } else {
                return ex;
            }
        }
        return ex;
    }
Catch exceptions as a last resort to avoid unresponsiveness.
s3stream/src/main/java/com/automq/stream/utils/FutureUtil.java