Feign Client : use jar 运行 (CompletableFuture.supplyAsync call Feign Client throw java.lang.IllegalArgumentException)

Feign Client : use jar running (CompletableFuture.supplyAsync call Feign Client throw java.lang.IllegalArgumentException)

当我启动 jdk 版本 8 -> 17,spring 云版本 2020.0.3,spring 启动 2.5.4;

CompletableFuture.supplyAsync调用Feign Client Code异常;


@FeignClient(value = "mall-product", configuration = {FeignErrorDecoder.class, FeignInterceptor.class, FeignConfig.class}, decode404 = true, contextId = "mall-product-productSku")
public interface ProductSkuFeignClient {
    default List<ProductSimpleResponse> findSimpleInfoByProductIds(List<Integer> productIds) {
        List<List<Integer>> lists = CompletableFutureUtil.splitList1000(productIds.stream().distinct().collect(Collectors.toList()));
        List<List<ProductSimpleResponse>> responses = CompletableFutureUtil.allOfTaskAndReturn(ids ->
                findSimpleInfoByProductIds(new ProductIdsRequest(ids)), lists);
        return responses.stream().flatMap(Collection::stream).collect(Collectors.toList());
    }

    @PostMapping("/api/product/sku/simple/info/by/productIds")
    List<ProductSimpleResponse> findSimpleInfoByProductIds(@RequestBody ProductIdsRequest request);
}
    public static <T, R> List<R> allOfTaskAndReturn(Function<T, R> function, List<T> objects) {
        List<CompletableFuture<R>> futures = new ArrayList<>();
        for (int i = 0; i < objects.size(); i++) {
            int finalI = i;
            futures.add(CompletableFuture.supplyAsync(() ->
                    function.apply(objects.get(finalI)), pool));
        }
        CompletableFuture<Void> allCompletableFuture = CompletableFuture
                .allOf(futures.toArray(new CompletableFuture[0]));
        return allCompletableFuture.thenApply(e ->
                futures.stream().map(CompletableFuture::join)
                        .collect(Collectors.toList())).join();
    }

2021-11-03 02:34:53.078 [http-nio-8095-exec-4] [ERROR] [5cc877af-3b0a-450e-af46-469b9c20378c] j.c.f.c.CommonGlobalExceptionHandler@toLog:57 - CompletionException java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.autoconfigure.condition.OnPropertyCondition] java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

这是一个已知问题。请参阅 GitHub 问题 here and a workaround that can be applied till the issue is fixed here