Skip to content

ensure generateId executes on the scheduler thread specified by publishOn #3711

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

qnnn
Copy link
Contributor

@qnnn qnnn commented Mar 3, 2025

Hello @spencergibb, I recently came across this code, which is intended to prevent the execution of uuid generate on the main thread. However, after applying the map function, the publisher returned by publishOn is no longer a MonoSubscribeOnCallable, but rather a MonoPublishOn. As a result, the first execution of idGenerator::generateId actually still occurs on the thread that subscribes to it.

protected Mono<String> randomId() {
return Mono.fromSupplier(idGenerator::generateId).map(UUID::toString).publishOn(Schedulers.boundedElastic());
}

@ryanjbaxter ryanjbaxter added this to the 4.1.8 milestone May 13, 2025
@ryanjbaxter ryanjbaxter merged commit 0769a21 into spring-cloud:main May 13, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this to Done in 2023.0.6 May 13, 2025
@github-project-automation github-project-automation bot moved this to Done in 2025.0.0 May 13, 2025
ryanjbaxter added a commit that referenced this pull request May 13, 2025
ensure generateId executes on the scheduler thread specified by publishOn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: No status
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants