Skip to content
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

Mark Scheduler threads to warn uses of block() inside one #1102

Closed
smaldini opened this issue Mar 1, 2018 · 2 comments
Closed

Mark Scheduler threads to warn uses of block() inside one #1102

smaldini opened this issue Mar 1, 2018 · 2 comments
Labels
type/enhancement A general enhancement
Milestone

Comments

@smaldini
Copy link
Contributor

smaldini commented Mar 1, 2018

We frequently observe users invoking Mono/Flux.block calls inside WebFlux Netty thread, or inside Schedulers.parallel()/Schedulers.single().

One solution would be to mark Threads via a ThreadFactory that extend Thread via a marking subclass, so later introspection via Thread.currentThread() instanceof NonBlockingThread could evaluate to true and even log or throw if Mono/Flux.block is called.

Encapsulation ideas are open, but 2 constraints to be useful would be:

  • to keep an external API to check for the current thread e.g. Schedulers.isInNonBlockingThread()
  • to offer a mean for external libraries such as reactor-netty to use the same marker when creating threads: could be that NonBlockingThread is public, or Schedulers can create ThreadFactory.
@smaldini smaldini added the type/enhancement A general enhancement label Mar 1, 2018
@smaldini smaldini added this to the 3.2.0.RELEASE milestone Mar 1, 2018
simonbasle added a commit that referenced this issue Mar 8, 2018
`block`, `blockOptional`, `blockFirst`, `blockLast`, `toIterable` and `toStream`
all check if the executing thread is NonBlocking and throw an
`IllegalStateException` if it is.
@simonbasle
Copy link
Member

fixed by 92df4ab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants