source: class MDCUtilTest {
  
    @Rule public RepeatRule rule;
    private static final ExecutorService EXECUTOR_SERVICE;
  
    @Test
    @Repeat(times = 10000, threads = 4)
    public void withMDCCommonPool() throws ExecutionException, InterruptedException {
  
target:     MDC.put("foo", "bar");
      final CompletableFuture<String> value1 = new CompletableFuture<>();
      final CompletableFuture<String> value2 = new CompletableFuture<>();
      CompletableFuture.runAsync(
          () -> value1.complete(MDC.get("foo")),
          withMDC())
          // Later stages should also have the MDC applied
          .thenRun(() -> value2.complete(MDC.get("foo")))
          .get();
      assertThat(value1.getNow(""), is("bar"));
      assertThat(value2.getNow(""), is("bar"));
  
      // MDC should not leak
      final Map<String, String> mdc = CompletableFuture
          .supplyAsync(MDC::getCopyOfContextMap)
          .get();
      assertThat(mdc, is(anyOf(nullValue(), is(emptyMap()))));
    }
  
  }