fix(task): prevent runner interrupt leakage on JDK 8 - #5
Merged
Merged
Conversation
Owner
Author
1.2.3 final verificationPR #5 was merged and released as
Release: https://github.com/wuuJiawei/ThreadForge/releases/tag/v1.2.3 Maven Central: https://repo.maven.apache.org/maven2/pub/lighting/threadforge-core/1.2.3/ |
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.
Root cause
On JDK 8, a cancelled
Channel.receive()can restore the interrupt flag on the scheduler worker. The task wrapper cleaned task state and context but left that flag set. When the worker was reused, the next channel wait immediately failed withCancelledExceptionbefore the scope deadline fired.scope.await()then returned normally becausedeadlineTriggeredwas still false.Fix
Clear the runner interrupt status in
TaskExecutionafter execution cleanup, including the queued-task early-return path. This keeps cancellation observable inside the task while preventing interrupt state from leaking into the next task on a reused worker.Added a deterministic regression test with an executor that intentionally retains worker interrupt state between commands.
Verification
mvn -B -ntp clean verify, 618/618 passedmvn -B -ntp clean verify, 618/618 passedChannelInterruptionTest: 50 rounds x 5 tests = 250 passesgit diff --check: passedtask=CANCELLED, token=falseafter a cancelled channel wait; the fixed test now consistently throwsScopeTimeoutException.This PR is a follow-up to the already released
v1.2.2and should be released as the next patch version after merge.