BobHanson / java2script

Java2Script provides an Eclipse Java to JavaScript transpiler, with a nearly complete implementation of the Java Virtual Machine with AWT and Swing in JavaScript, with simple, automated parallel creation of both class files and js files. To date, over 600 applets have been converted.

Home Page:https://chemapps.stolaf.edu/swingjs/examples.htm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callbacks are not being executed for already completed completion stages.

warownia1 opened this issue · comments

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.