You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When virtual threads are enabled with reactor.schedulers.defaultBoundedElasticOnVirtualThreads property, BoundedElasticThreadPerTaskScheduler thread leaks interrupted signal into user code. Below is the test that shows that:
I might be missing something here, but It seems that the interrupted flag persists because the thread isn’t in a blocking state, which prevents the flag from resetting.
In the first test, the interruption occurs before the error handler (onErrorResume) is executed, so the interrupted flag leaks into user code. However, in the second test, the error handler (onErrorResume) executes before the interrupt is triggered, which allows the test case to pass as the interrupted flag hasn't been set yet.
I was wondering if this approach might help: SchedulerTask.dispose() in BoundedElasticThreadPerTaskScheduler
if (isRunning(previousState)) {
if (hasFuture(previousState)) {
this.scheduledFuture.cancel(true);
}
if (this.carrier.getState() == Thread.State.WAITING ||
this.carrier.getState() == Thread.State.TIMED_WAITING ||
this.carrier.getState() == Thread.State.BLOCKED) {
this.carrier.interrupt();
}
return;
}
After this change, the test cases pass as expected. It ensures that the interrupt is only triggered when the thread is in a waiting or blocked state, potentially avoiding unnecessary leaks into user code.
What do you think about this adjustment? I'm open to feedback if I misunderstood anything! 🙇
When virtual threads are enabled with
reactor.schedulers.defaultBoundedElasticOnVirtualThreads
property, BoundedElasticThreadPerTaskScheduler thread leaksinterrupted
signal into user code. Below is the test that shows that:Expected Behavior
The lambda which is called by
onErrorResume
should be run on a thread that is not interrupted.Actual Behavior
The lambda which is called by
onErrorResume
is run on an interrupted Thread.Reactor Core version: 3.6.6
Notes
Bellow test passes if an exception is thrown inside
map
function:The text was updated successfully, but these errors were encountered: