@Test public void run() throws Exception { ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.afterPropertiesSet(); final ThreadPoolTaskExecutor innerTaskExecutor = new MdcThreadPoolTaskExecutor(); innerTaskExecutor.afterPropertiesSet(); final FutureTask<String> innerTask = new FutureTask<String>(new Callable<String>() { @Override public String call() throws Exception { return MDC.get("key"); } }); taskExecutor.execute(new Runnable() { @Override public void run() { MDC.put("key", "1"); innerTaskExecutor.execute(innerTask); } }); assertThat(innerTask.get(), is(equalTo("1"))); Thread.sleep(1000); final FutureTask<String> innerTask2 = new FutureTask<String>(new Callable<String>() { @Override public String call() throws Exception { return MDC.get("key"); } }); taskExecutor.execute(new Runnable() { @Override public void run() { MDC.put("key", "2"); innerTaskExecutor.execute(innerTask2); } }); assertThat(innerTask2.get(), is(equalTo("2"))); }
@Override public void execute(Runnable command) { super.execute(wrap(command, getContextForTask())); }
MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor { @Override public void execute(Runnable command) { super.execute(wrap(command, getContextForTask())); } }
MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor { @Override public void execute(Runnable command) { super.execute(wrap(command, getContextForTask())); } MdcThreadPoolTaskExecutor();  MdcThreadPoolTaskExecutor(Map<String, String> fixedContext); }
MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor { @Override public void execute(Runnable command) { super.execute(wrap(command, getContextForTask())); } MdcThreadPoolTaskExecutor();  MdcThreadPoolTaskExecutor(Map<String, String> fixedContext); @Override void execute(Runnable command); static Runnable wrap(final Runnable runnable, final Map<String, String> context); }
MdcThreadPoolTaskExecutor extends ThreadPoolTaskExecutor { @Override public void execute(Runnable command) { super.execute(wrap(command, getContextForTask())); } MdcThreadPoolTaskExecutor();  MdcThreadPoolTaskExecutor(Map<String, String> fixedContext); @Override void execute(Runnable command); static Runnable wrap(final Runnable runnable, final Map<String, String> context);  }