Skip to content

fix(task): prevent runner interrupt leakage on JDK 8 - #5

Merged
wuuJiawei merged 1 commit into
mainfrom
fix/jdk8-channel-deadline
Aug 10, 2026
Merged

wuuJiawei merged 1 commit into
mainfrom
fix/jdk8-channel-deadline

Conversation

@wuuJiawei

Copy link
Copy Markdown
Owner

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 with CancelledException before the scope deadline fired. scope.await() then returned normally because deadlineTriggered was still false.

Fix

Clear the runner interrupt status in TaskExecution after 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

  • Local JDK 8: mvn -B -ntp clean verify, 618/618 passed
  • Local JDK 17: mvn -B -ntp clean verify, 618/618 passed
  • JDK 8 ChannelInterruptionTest: 50 rounds x 5 tests = 250 passes
  • git diff --check: passed
  • The pre-fix reproducer reached task=CANCELLED, token=false after a cancelled channel wait; the fixed test now consistently throws ScopeTimeoutException.

This PR is a follow-up to the already released v1.2.2 and should be released as the next patch version after merge.

@wuuJiawei
wuuJiawei merged commit 209089c into main Aug 10, 2026
5 checks passed
@wuuJiawei

wuuJiawei commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

1.2.3 final verification

PR #5 was merged and released as v1.2.3.

Verification Result
PR CI core matrix JDK 8 / 11 / 17 / 21 passed
Local JDK 8 mvn -B -ntp clean verify 618 tests, 0 failures/errors/skips
Local JDK 17 mvn -B -ntp clean verify 618 tests, 0 failures/errors/skips
Local JDK 17 mvn -B -ntp clean install 618 tests, 0 failures/errors/skips
Release deploy verification 618 tests, coverage gate passed, signing and Central validation passed
threadforge-slf4j 4 tests passed
threadforge-micrometer 1 test passed
Examples 4 sources compiled and packaged
Benchmarks JMH shaded jar compiled and packaged
Regression target ChannelInterruptionTest 5/5 passed on JDK 8 and JDK 17
Maven Central pub.lighting:threadforge-core:1.2.3 jar and pom return HTTP 200
GitHub Release workflow Success on JDK 21

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant