Skip to content

Support multiple TaskDecorator beans #45295

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

Closed
mhalbritter opened this issue Apr 25, 2025 · 5 comments
Closed

Support multiple TaskDecorator beans #45295

mhalbritter opened this issue Apr 25, 2025 · 5 comments
Assignees
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@mhalbritter
Copy link
Contributor

mhalbritter commented Apr 25, 2025

In #43190 (landed in 3.5.0-M1), support for TaskDecorator has been added. If a bean is in the context, it's automatically applied to SimpleAsyncTaskExecutorBuilder and ThreadPoolTaskExecutorBuilder.

However, if there are multiple TaskDecorator beans are in the context, none is applied. That's because we use .getIfUnique.

I think that's somewhat confusing. It would be better to fail if there is more than one bean, or even better, support multiple TaskDecorators (maybe using composition?).

@mhalbritter mhalbritter added the type: enhancement A general enhancement label Apr 25, 2025
@mhalbritter mhalbritter added this to the 3.x milestone Apr 25, 2025
@mhalbritter
Copy link
Contributor Author

Not sure if this is an enhancement or a bug.

@nosan
Copy link
Contributor

nosan commented Apr 25, 2025

In #43190 (landed in 3.5.0-M1), support for TaskDecorator has been added. If a bean is in the context, it is automatically applied to SimpleAsyncTaskExecutorBuilder and ThreadPoolTaskExecutorBuilder.

#43190 was specifically about scheduled tasks 😃

However, if there are multiple TaskDecorator beans in the context, none of them are applied. This is because .getIfUnique is used.

This logic has existed from the very beginning: #1563

I think that's somewhat confusing. It would be better to fail if there is more than one bean, or even better, support multiple TaskDecorator instances (perhaps using composition?).

I believe composition is a good idea. The org.springframework.core.task.support.CompositeTaskDecorator can be used.

Not sure if this is an enhancement or a bug.

I think this is an enhancement

@mhalbritter
Copy link
Contributor Author

Oh, sorry @nosan I mixed things up. Thanks for digging.

@nosan
Copy link
Contributor

nosan commented Apr 25, 2025

@mhalbritter

Could you kindly assign this one to me, please?

@snicoll
Copy link
Member

snicoll commented Apr 30, 2025

Closing in favor of PR 45302

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2025
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Apr 30, 2025
@snicoll snicoll removed this from the 3.x milestone Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants