Fix StopWatch's stopInstant match stopTimeNanos when split is called#1610
Merged
garydgregory merged 2 commits intoapache:masterfrom Mar 4, 2026
Merged
Fix StopWatch's stopInstant match stopTimeNanos when split is called#1610garydgregory merged 2 commits intoapache:masterfrom
garydgregory merged 2 commits intoapache:masterfrom
Conversation
Contributor
Author
|
There is a CI test failure but it appears to be unrelated. |
Member
|
Yep, this is a "random" and recurring issue. I'll take a look at any side effects for the PR later today or tomorrow. |
garydgregory
added a commit
that referenced
this pull request
Mar 4, 2026
Member
|
I merged the PR. TY @larshelge 👍 |
Contributor
Author
|
Great, really appreciate the quick response @garydgregory! |
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.
This PR improves consistency in
StopWatch. InStopWatchtwo variables are used to represent the stop time, using long/milliseconds andInstantrespectively, to prepare for Java 8 removal.For most operations including start, stop and suspend, the two variables are set together to the approximately same time.
The exception is for the split operation, where only the Instant variable is set. This is inconsistent and is problematic when you extend the
StopWatchclass with a custom class, as the long/milliseconds variable is private and not accessible from the outside, while the Instant variable is the only accessible variable through thegetStopInstant. ThegetStopTimemethod delegates togetStopInstant. CallinggetStopTimeaftersplitis called, without also callingstop, is causing a nullpointer exception.No AI was used for this PR.