Conversation
Signed-off-by: hocaron <kkannu0407@gmail.com>
hocaron
force-pushed
the
4338-undecoratedRunnable
branch
from
July 26, 2026 15:09
b9934ae to
3502eaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
UndecoratedRunnable, a marker interface forRunnabletasks that must besubmitted to a
Schedulerwithout the decoration registered viaSchedulers.onScheduleHook(String, Function).Schedulers.onSchedule(Runnable)now returns such tasks as-is.
Why
Library-internal, self-rescheduling maintenance tasks (resource eviction and the
like) never execute user code, yet they currently receive the same task decoration
as user tasks. With
Hooks.enableAutomaticContextPropagation()enabled, thatdecoration captures the scheduling caller's
ThreadLocalstate into the pendingtask; because such tasks re-schedule themselves from inside the restored snapshot
scope, the captured request-scoped state is retained for the lifetime of the
resource (437MB observed in production — see #4338 and reactor/reactor-netty#4299).
There is no way to opt out today: every asynchronous
Schedulerbuilt via theSchedulersfactory methods funnels tasks throughSchedulers.onSchedule(...).reactor-netty had to hand-write a bypassing
Schedulerin reactor/reactor-netty#4300;reactor-pool's eviction task has the same shape and still affects direct
reactor-pool users. This marker gives libraries a first-class opt-out while
keeping the standard schedulers, including schedulers supplied by the user.
The name mirrors the existing
NonBlockingthread marker in the same package.Happy to rename or reshape the API if you prefer a different form.
Changes
reactor.core.scheduler.UndecoratedRunnablemarker interface (no methods).Schedulers.onSchedule(Runnable)skips hook application for tasks implementing it.The added
instanceofsits behind the existinghook != nullshort-circuit, so itonly executes when a hook is registered, and is negligible next to the wrapper
allocation it avoids (the class already type-checks similarly with
Thread instanceof NonBlocking).SchedulersHooksTest: a directonScheduleunit test and aparameterized end-to-end test across PARALLEL / BOUNDED_ELASTIC / SINGLE /
EXECUTOR_SERVICE / EXECUTOR verifying the hook is not applied to marked tasks.
User-facing tasks should not implement the marker (documented in the javadoc):
skipping decoration also skips user-registered hooks such as MDC propagation.
Fixes #4338.