title: Is Mono.toFuture() blocking?
body: <p>From the <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#block--" rel="nofollow noreferrer">Official Documentation of Mono#block()</a> it is said that:</p>
  
  <blockquote>
    <p>Subscribe to this Mono and <strong>block indefinitely</strong> until a next signal is received. Returns that value, or null if the Mono completes empty. In case the Mono errors, the original exception is thrown (wrapped in a RuntimeException if it was a checked exception).</p>
  </blockquote>
  
  <p>So it is sure that block() method is blocking and it will not execute the next line untill <code>block()</code> resolved.</p>
  
  <p>But my confusion is while I was using <code>toFuture()</code> expecting it will be non-blocking but it is behaving exactly like <code>block</code> method. And in the <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#toFuture--" rel="nofollow noreferrer">Documentation of Mono#toFuture()</a> it is stated:</p>
  
  <blockquote>
    <p>Transform this Mono into a CompletableFuture completing on onNext or onComplete and failing on onError.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/gAJSR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gAJSR.png" alt="Mono#toFuture()"></a></p>
  
  <p>Not much clear. Nowhere in this doc said <strong><code>Mono#toFuture()</code> is blocking</strong>. </p>
  
  <ol>
  <li>Please confirm me if <code>toFuture()</code> method blocking or non-blocking?</li>
  <li>Also If it is <strong>non-blocking</strong> then, which thread will responsible to execute the code inside <code>CompletableFuture</code>?</li>
  </ol>
  
  <p><strong>Update: added code snippet</strong></p>
  
  <p>using <strong><code>Mono.block()</code></strong> method:</p>
  
  <pre><code>    long time = System.currentTimeMillis();
      String block = Mono.fromCallable(() -&gt; {
          logger.debug("inside in fromCallable() block()");
          //Upstream httpcall with apache httpClient().
          // which takes atleast 1sec to complete.
          return "Http response as string";
      }).block();
      logger.info("total time needed {}", (System.currentTimeMillis()-time));
  
      return CompletableFuture.completedFuture(block);
  </code></pre>
  
  <hr>
  
  <p>Using <strong><code>Mono.ToFuture()</code></strong> method:</p>
  
  <pre><code>    long time = System.currentTimeMillis();
      CompletableFuture&lt;String&gt; toFuture = Mono.fromCallable(() -&gt; {
          logger.debug("inside in fromCallable() block()");
          //Upstream httpcall with apache httpClient().
          // which takes atleast 1sec to complete.
          return "Http response as string";
      }).toFuture();
      logger.info("total time needed {}", (System.currentTimeMillis()-time));
      return toFuture;
  </code></pre>
  
  <p><strong>these two code snippets behaves exactly same.</strong></p>