spring-projects / spring-projects/spring-security
Better docs on "inter-op" with @Async
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
As far as I understand when using Virtual threads you should not use Thread pools like this:
@Configuration
class ServiceExecutorConfig : AsyncConfigurer {
override fun getAsyncExecutor(): Executor {
val taskExecutor = ThreadPoolTaskExecutor().apply {
corePoolSize = 15
maxPoolSize = 50
setQueueCapacity(100)
initialize()
}
return DelegatingSecurityContextAsyncTaskExecutor(taskExecutor)
}
}
But instead something like:
@Configuration
@EnableAsync
class AsyncConfig(
private val builder: SimpleAsyncTaskExecutorBuilder
) {
@Bean(name = ["secExecutor"])
fun secExecutor(): AsyncTaskExecutor {
// With spring.threads.virtual.enabled=true this builder creates
// a SimpleAsyncTaskExecutor that uses a *new virtual thread per task*.
val delegate = builder
.threadNamePrefix("async-")
.build()
return DelegatingSecurityContextAsyncTaskExecutor(delegate)
}
}
I'm trying to find good official docs on how to handle this, the first results are blogs recommending the ThreadPoolTaskExecutor approach.
I also find this, which does not cover a simple way of making Spring security work with Async out of the box:
https://docs.spring.io/spring-security/reference/features/integrations/concurrency.html
I'm not sure if this is something that it would make sense if the framework just solved with reasonable defaults?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Spring Security concurrency integration documentation linked in the issue and compare its guidance with the provided @Async, virtual-thread, and DelegatingSecurityContextAsyncTaskExecutor examples. Done means the official documentation clearly explains the recommended virtual-thread configuration and how Spring Security context propagation works with it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100