@@ -92,13 +92,15 @@ void simpleAsyncTaskExecutorBuilderShouldReadProperties() {
9292 "spring.task.execution.simple.reject-tasks-when-limit-reached=true" ,
9393 "spring.task.execution.simple.concurrency-limit=1" ,
9494 "spring.task.execution.shutdown.await-termination=true" ,
95- "spring.task.execution.shutdown.await-termination-period=30s" )
95+ "spring.task.execution.shutdown.await-termination-period=30s" ,
96+ "spring.task.execution.propagate-context=true" )
9697 .run (assertSimpleAsyncTaskExecutor ((taskExecutor ) -> {
9798 assertThat (taskExecutor ).hasFieldOrPropertyWithValue ("cancelRemainingTasksOnClose" , true );
9899 assertThat (taskExecutor ).hasFieldOrPropertyWithValue ("rejectTasksWhenLimitReached" , true );
99100 assertThat (taskExecutor .getConcurrencyLimit ()).isEqualTo (1 );
100101 assertThat (taskExecutor .getThreadNamePrefix ()).isEqualTo ("mytest-" );
101102 assertThat (taskExecutor ).hasFieldOrPropertyWithValue ("taskTerminationTimeout" , 30000L );
103+ assertThat (taskExecutor ).hasFieldOrPropertyWithValue ("propagateContext" , true );
102104 }));
103105 }
104106
@@ -253,6 +255,16 @@ void simpleAsyncTaskExecutorBuilderUsesVirtualThreadsWhenEnabled() {
253255 });
254256 }
255257
258+ @ Test
259+ void asyncTaskExecutorShouldApplyContextPropagatingDecoratorWhenEnabled () {
260+ this .contextRunner .withPropertyValues ("spring.task.execution.propagate-context=true" )
261+ .run ((context ) -> {
262+ assertThat (context ).hasSingleBean (ContextPropagatingTaskDecorator .class );
263+ assertThat (context .getBean (ContextPropagatingTaskDecorator .class ))
264+ .isSameAs (context .getBean ("contextPropagatingTaskDecorator" ));
265+ });
266+ }
267+
256268 @ Test
257269 void taskExecutorWhenHasCustomTaskExecutorShouldBackOff () {
258270 this .contextRunner .withBean ("customTaskExecutor" , Executor .class , SyncTaskExecutor ::new ).run ((context ) -> {
0 commit comments