title: How to retain slf4j MDC logging context in CompletableFuture?
body: <p>When executing async <code>CompletableFuture</code>, the parent threadcontext and moreover the <code>org.slf4j.MDC</code> context is lost.</p>
  
  <p>This is bad as I'm using some kind of "fish tagging" to track logs from one request among multiple logfiles. </p>
  
  <p><code>MDC.put("fishid", randomId())</code></p>
  
  <p>Question: how can I retain that id during the tasks of <code>CompletableFutures</code> in general?</p>
  
  <pre><code>List&lt;CompletableFuture&lt;UpdateHotelAllotmentsRsp&gt;&gt; futures =
      tasks.stream()
          .map(task -&gt; CompletableFuture.supplyAsync(
              () -&gt; businesslogic(task))
          .collect(Collectors.toList());
  
  List results = futures.stream()
      .map(CompletableFuture::join)
      .collect(Collectors.toList());
  
  public void businesslogic(Task task) {
         LOGGER.info("mdc fishtag context is lost here");
  }
  </code></pre>