title: Explanation needed, applyAsync with nested allOf treats CompletionStage as finished
body: <p>In my app I have 3 future calls, that are done in parallel and when a response for one of them is received, I have another 3 requests that all should finish before proceeding with code execution, precisely the <code>DeferredResult</code> from spring.</p>
  
  <p>After a while, I realized that page is sometimes rendered before the latter 3 requests are done. Original source code (ommited logic for simplicity):</p>
  
  <pre><code>public DeferredResult&lt;String&gt; someControllerMethod() {
  
      DeferredResult&lt;String&gt; result = new DeferredResult();
  
      CompletableFuture.allOf(
          future1(),
          future2(),
          future3()
      )
      .whenComplete((aVoid, throwable) -&gt; result.setResult("something"));
  
      return result;
  }
  
  public CompletableFuture&lt;?&gt; future3() {
      return someService.asyncCall()
          .thenApplyAsync(response -&gt; {
              ....
              return CompletableFuture.allOf(
                  future4(),
                  future5(),
                  future6()
              );
          }
      );
  }
  </code></pre>
  
  <p>With <code>thenApplyAsync</code> sometimes <code>DeferredResult</code> is completed before actual future, while changing to <code>thenComposeAsync</code> seems solve the issue. Could someone explain me why? Or it's a bug in my code somewhere and it should not behave this way?</p>