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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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());
}

…shOn.

Signed-off-by: qnnn <65326092+qnnn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants