Skip to content

Make default value of StuckThreadDetectionValve#interruptThreadThreshold explicit - #1034

Open
lihongyi87 wants to merge 1 commit into
apache:11.0.xfrom
lihongyi87:fix-stuckthread-interruptthreadthreshold-default
Open

Make default value of StuckThreadDetectionValve#interruptThreadThreshold explicit#1034
lihongyi87 wants to merge 1 commit into
apache:11.0.xfrom
lihongyi87:fix-stuckthread-interruptthreadthreshold-default

Conversation

@lihongyi87

@lihongyi87 lihongyi87 commented Aug 2, 2026

Copy link
Copy Markdown

The interruptThreadThreshold field of StuckThreadDetectionValve had no explicit initialiser, so it relied on the Java default of 0. This value disables thread interruption.

However, the Javadoc for the field (line 72) and the setter (line 118), as well as the user-facing documentation in webapps/docs/config/valve.xml (line 2677), all state that the default is -1:

  • StuckThreadDetectionValve.java:72 — "In seconds. Default is -1 to disable interruption."
  • StuckThreadDetectionValve.java:118 — "The default is -1."
  • valve.xml:2677 — "Default is -1 which disables the feature."

This patch makes the default explicit (= -1) so the code matches the documented behaviour.

Behaviour impact: none. The interruption logic uses interruptThreadThreshold > 0 (lines 190 and 222), so both 0 and -1 disable the feature. This change only aligns the code with its documented default.

Testing: the existing test (TestStuckThreadDetectionValve) calls setInterruptThreadThreshold(5) and does not rely on the default value, so it is unaffected.

Backport note: The same issue exists on the 9.0.x and 10.1.x branches
(the interruptThreadThreshold field is also uninitialised there while the
Javadoc states the default is -1). I have only raised this PR against
11.0.x for now - happy to provide backports if desired.

The interruptThreadThreshold field relied on the Java default of 0
which disables thread interruption. The Javadoc and valve
documentation both state the default is -1. Make the default
explicit (-1) so the code matches the documented behaviour.
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