I believe this is a request. Are there any plans soon by the Sping Team for an asynchronous Auth Server?
Currently, when querying a DocDB database, I use this for my UserDetailsService. But I do get memory leaks in the server log, I think because Project Loom is still in beta.
Just wondered if there might be upcoming support for a Webflux AuthServer?
// using Java Virtual Threads (Project Loom), since Spring does not yet support reactive Auth Servers // https://github.com/spring-projects/spring-authorization-server/issues/152 // https://kt.academy/article/dispatcher-loom
@Configuration
class ExecutorConfig {
private val executor = Executors.newVirtualThreadPerTaskExecutor()
@Bean
fun coroutineDispatcher(): CoroutineContext = executor.asCoroutineDispatcher()
@PreDestroy
fun cleanUp() {
executor.close()
}
}
@Service
internal class VirtualThreadManager(
@Autowired
private val userRepo: UserRepositoryImpl,
private val dispatcher: CoroutineContext
) {
internal fun fetchUserEntity(userEmail: String): UserEntity? {
return try {
// run the coroutine blocking the current thread until it completes
runBlocking {
// switch to the custom dispatcher created from the executor
withContext(dispatcher) {
getUserEntity(userEmail)
}
}
} catch (ex: RejectedExecutionException) {
throw RuntimeException("Executor was shut down, unable to execute task", ex)
}
}
// get userEntity from DocDatabase
private suspend fun getUserEntity(userEmail: String): UserEntity? {
val userEntity = userRepo.getUserByEmail(userEmail)
return userEntity
}
}
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior.
Expected behavior A clear and concise description of what you expected to happen.
Sample
A link to a GitHub repository with a minimal, reproducible sample.
Reports that include a sample will take priority over reports that do not. At times, we may require a sample, so it is good to try and include a sample up front.
Comment From: sjohnr
@dreamstar-enterprises, I believe this has been answered in this comment.