项目场景:
请求某个接口(synchronized方法) --> 执行异步调用超时方法 --> 超时方法一直超时,get方法导致一直阻塞
问题描述:
请求某接口,第一次请求时会被阻塞,后续请求无法再次请求该接口,第一次请求未结束,由于该接口使用synchronized关键字,导致后续请求无法再次请求该接口,导致阻塞的原因是使用了CompletableFuture来做异步操作,使用方法不当导致。
public String getFlowInstanceRid(String orderId, String info, String area, String type) throws InterruptedException, ExecutionException {
CompletableFuture<String> future = new CompletableFuture<>();
ExecutorService executorService =