Questions tagged [completable-future]

In Java 8, a Future that may be explicitly completed (setting its value and status), and may include dependent functions and actions that trigger upon its completion.

Introduced in Java 8, CompletableFuture is a Future that may be explicitly completed (setting its value and status), and may include dependent functions and actions that trigger upon its completion.

When two or more threads attempt to complete, completeExceptionally, or cancel a CompletableFuture, only one of them succeeds. Oracle Documentation

1386 questions
-1
votes
1 answer

How to receive Future[] Result response in Controllers, I got error in Controllers like actual:Future[Result] expected Action Result?

In Services, i m calling the endpoint service and got response as Future[] Result. I need to send the Future[] Result to Controllers. In Controllers i should respond the result via Ok(response). //In Controllers i have to receive the response from…
user3278612
  • 201
  • 2
  • 11
-1
votes
1 answer

Error saying "CompletableFuture(Object) has private access in CompletableFuture" when implementing CompletableFuture

I am implementing CompletableFuture as below but getting an error saying CompletableFuture(Object) has private access in CompletableFuture public CompletableFuture init(B b) { C c = new C(); CompletableFuture future = new…
Malinda
  • 336
  • 2
  • 12
-2
votes
1 answer

Java Future verify if success or failure?

When calling the Kafka Producer, is there a way to verify if the result is success or failure? I get back a Future but I do not know how to verify if it is successful or not successful. Or is it the fact that if this is returned,…
stackerstack
  • 243
  • 4
  • 16
-2
votes
1 answer

Throw actual exception from completeablefuture

I am making parallel call using completablefuture like below, public Response getResponse() { Response resultClass = new Response(); try { CompletableFuture> classAFuture = CompletableFuture.supplyAsync(() ->…
Lolly
  • 34,250
  • 42
  • 115
  • 150
-2
votes
1 answer

Java asynchronous return of CompletableFuture

If we have AsyncResponse response variable we can write something like: CompletableFuture#thenAccept(response::resume). I don't understand how can we pass boolean resume(Object response) method from AsyncResponse class to thenAccept() which takes…
Freeman
  • 232
  • 1
  • 2
  • 11
-3
votes
2 answers

CompletableFuture takes more time - Java 8

I have two snippets of code which are technically same, but the second one takes 1 sec extra then the first one. The first one executes in 6 sec and the second in 7. Double yearlyEarnings =…
Robin
  • 6,879
  • 7
  • 37
  • 35
1 2 3
92
93