  @Test
  public void testNullIntermediateValue() {

    Assert.assertEquals(
        AsyncTrampoline.<Integer>asyncWhile(
            i -> i != null && i < 10,
            i -> {
              Integer next;
              if (i == null) {
                next = 5;
              } else if (i == 4) {
                next = null;
              } else {
                next = i + 1;
              }
              return StageSupport.completedStage(next);
            },
            0).toCompletableFuture().join(),
        null);
  }