Make default value of StuckThreadDetectionValve#interruptThreadThreshold explicit - #1034
Open
lihongyi87 wants to merge 1 commit into
Open
Conversation
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.
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.
The
interruptThreadThresholdfield ofStuckThreadDetectionValvehad no explicit initialiser, so it relied on the Java default of0. 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 both0and-1disable the feature. This change only aligns the code with its documented default.Testing: the existing test (
TestStuckThreadDetectionValve) callssetInterruptThreadThreshold(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
interruptThreadThresholdfield is also uninitialised there while theJavadoc states the default is
-1). I have only raised this PR against11.0.x for now - happy to provide backports if desired.