Questions tagged [completion-stage]

Java 8 common API interface of a possibly asynchronous computation, that performs an action or computes a value when another CompletionStage completes. Note: this tag is a bit different from `completable-future`, which is a default implementation of this CompletionStage API

Java 8 common API interface of a possibly asynchronous computation, that performs an action or computes a value when another CompletionStage completes:

https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html

40 questions
0
votes
0 answers

how to change method signature from void to CompletionStage?

class AnotherClass { Option validateAndGetInt(Xyz xyz, Mno mno, String strValue) { if (strValue != null) { int intValue = 1; try{ intValue = Integer.parseInt(strValue); …
sau123
  • 352
  • 5
  • 18
0
votes
0 answers

Why thenApply and thenApplySync not working with completion stage

First of all, it is obvious that I don't understand the thenApply well and that's why I am coming with a compiler error, but I tried to search and couldn't. Here is my simple code: import java.util.concurrent.CompletionStage; public class Main5 { …
0
votes
0 answers

how to convert result from CompletionStage

I access an API and it returns the result as success, but I want to convert result to type integer, when I try, it show me the error cannot convert from completionStage to integer My code WSRequest req1 =…
0
votes
2 answers

Is it possible to add new CompletableFutures to CompletableFuture.allOf() dynamically?

I have a database with 3 tables: Table A which contains data of A objects Table B which contains data of B objects Table C which contains data of C objects A objects can have 0 or 1 B objects B objects can have 0 or 1 C objects (I know, these could…
0
votes
0 answers

Chaining several CompletionStage, how is this handled in memory?

I made a function that is called allOfSequentialSupplierCombine(...) this function basically takes a linkedList of Suppliers of promises, and then it executes the promises one by one by chaining them recursively and then it builds an array of the…
0
votes
2 answers

Java : Overridden method does not throw 'java.lang.Throwable'

I am getting following compile time error call(play.mvc.Http.Context) in actions.Headers cannot override call(play.mvc.Http.Context) in play.mvc.Action [error] overridden method does not throw java.lang.Exception [error] public…
swaheed
  • 3,671
  • 10
  • 42
  • 103
0
votes
1 answer

Is there a way to execute an action after all descendant stages complete?

CompletionStage.whenComplete() executes an action after the current stage completes, but what happens if the stage has dependent stages? Is there a way to execute an action after all dependent stages have completed when I don't have access to the…
Gili
  • 86,244
  • 97
  • 390
  • 689
0
votes
1 answer

Dynamically set the thread pool size for CompletionStages in Play! with Akka

In my web application, I am using Play! framework that builds on Akka for managing threads. In a specific case, where I compose many CompletionStages that collects data from external services, I want to control the number of parallel requests in…
AHH
  • 981
  • 2
  • 10
  • 26
-1
votes
1 answer

Java - sync call inside async thenCompose

Consider below code as I am not able to find better words to ask the question: CompletionStage callingAsyncFunction(int developerId) { return getManagerIdByDeveloperId(developerId) .thenCompose(id -> …
-2
votes
1 answer

How do I unit test whenCompleteAsync on a lambda with a http request?

I want to create a unit test for the following class: @Service public class XService{ public String getSomething(String inputField) { final SomeEntity someEntity1 = new SomeEntity(); final AtomicReference
1 2
3