This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new ca21966b9 Internal refactoring
ca21966b9 is described below
commit ca21966b93b6cc43ce2ec3a37018921d66251ac2
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Mar 4 16:08:05 2026 -0500
Internal refactoring
---
.../java/org/apache/commons/lang3/time/StopWatch.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/time/StopWatch.java
b/src/main/java/org/apache/commons/lang3/time/StopWatch.java
index a329537f0..d9d413733 100644
--- a/src/main/java/org/apache/commons/lang3/time/StopWatch.java
+++ b/src/main/java/org/apache/commons/lang3/time/StopWatch.java
@@ -689,8 +689,7 @@ public void split() {
if (runningState != State.RUNNING) {
throw new IllegalStateException("Stopwatch is not running.");
}
- stopTimeNanos = System.nanoTime();
- stopInstant = Instant.now();
+ stopSet();
splitState = SplitState.SPLIT;
splits.add(new Split(String.valueOf(splits.size()),
Duration.ofNanos(stopTimeNanos - startTimeNanos)));
}
@@ -711,8 +710,7 @@ public void split(final String label) {
if (runningState != State.RUNNING) {
throw new IllegalStateException("Stopwatch is not running.");
}
- stopTimeNanos = System.nanoTime();
- stopInstant = Instant.now();
+ stopSet();
splitState = SplitState.SPLIT;
splits.add(new Split(label, Duration.ofNanos(stopTimeNanos -
startTimeNanos)));
}
@@ -764,12 +762,16 @@ public void stop() {
throw new IllegalStateException("Stopwatch is not running.");
}
if (runningState == State.RUNNING) {
- stopTimeNanos = System.nanoTime();
- stopInstant = Instant.now();
+ stopSet();
}
runningState = State.STOPPED;
}
+ private void stopSet() {
+ stopTimeNanos = System.nanoTime();
+ stopInstant = Instant.now();
+ }
+
/**
* Suspends this StopWatch for later resumption.
*
@@ -783,8 +785,7 @@ public void suspend() {
if (runningState != State.RUNNING) {
throw new IllegalStateException("Stopwatch must be running to
suspend.");
}
- stopTimeNanos = System.nanoTime();
- stopInstant = Instant.now();
+ stopSet();
runningState = State.SUSPENDED;
}