Closed maoyutofu closed 1 year ago
The synchronization result cannot be obtained through the get method in CompletableFuture
4.2.5
final CompletableFuture<List<JsonObject>> queryFuture = new CompletableFuture<>(); client.findWithOptions("table_name", new JsonObject(), new FindOptions().setLimit(10).setSkip(0)).onComplete(ar -> { if (ar.succeeded()) { queryFuture.complete(ar.result()); } else { queryFuture.complete(null); } }); final CompletableFuture<List<JsonObject>> resultFuture = queryFuture.thenApply(dataList -> dataList); try { System.out.println(resultFuture.get()); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); }
I assume the code is invoked on the event loop, that gets blocked by resultFuture.get().
resultFuture.get()
You need to rework this part of the code to avoid blocking.
Questions
The synchronization result cannot be obtained through the get method in CompletableFuture
Version
4.2.5
Context