Skip to content

Add support for multiple TaskDecorator beans #45302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Apr 25, 2025

See #45295

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 25, 2025
Previously, only a single TaskDecorator bean, if unique, was applied
to the auto-configured TaskExecutor or Scheduler. With this change,
if multiple TaskDecorator beans are defined, they will be combined
into a `CompositeTaskDecorator` and applied accordingly.

Signed-off-by: Dmytro Nosan <[email protected]>
@@ -451,6 +485,10 @@ void shouldNotAliasApplicationTaskExecutorWhenBootstrapExecutorAliasIsDefined()
});
}

private TaskDecorator createTaskDecorator() {
return (runnable) -> runnable;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A custom implementation instead of Mockito.mock(TaskDecorator.class) to avoid this exception

Exception in thread "scheduling-1" java.lang.NullPointerException: Cannot invoke "java.lang.Runnable.run()" because "this.decoratedRunnable" is null
	at org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler$DelegatingRunnableScheduledFuture.run(ThreadPoolTaskScheduler.java:508)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants