Skip to content

Callbacks are not being executed for already completed completion stages. #208

@warownia1

Description

@warownia1

Callbacks attached to already completed CompletionStages returned by CompletableFuture#completedStage() static factory method should be called just after being attached, but they are not. The issue doesn't occur when #completedFuture is being used instead.

Example:

public class CompletionStageTest
{
  public static void main(String[] args) {
    CompletableFuture<String> future1 = new CompletableFuture<>();
    future1.thenAccept(System.out::println);
    future1.complete("Future 1");
    
    CompletionStage<String> future2 = CompletableFuture.completedFuture("Future 2");
    future2.thenAccept(System.out::println);
    
    CompletionStage<String> future3 = CompletableFuture.completedStage("Future 3");
    future3.thenAccept(System.out::println);
  }
}

The last callback printing "Future 3" is not executed but it should be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions