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 f5ab41fed [LANG-1762] StopWatch methods should not delegate to 
deprecated methods
f5ab41fed is described below

commit f5ab41fed1acf203670ef11fecac882595e406b6
Author: Gary D. Gregory <[email protected]>
AuthorDate: Tue Jan 14 15:27:11 2025 -0500

    [LANG-1762] StopWatch methods should not delegate to deprecated methods
---
 src/changes/changes.xml                             |  1 +
 .../org/apache/commons/lang3/time/StopWatch.java    | 21 ++++++++++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4d8aa0085..9ad14108b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -77,6 +77,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Undeprecate ObjectUtils.toString(Object).</action>
     <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Fix Spotbugs [ERROR] Medium: The field 
org.apache.commons.lang3.builder.DiffBuilder$SDiff.leftSupplier is transient 
but isn't set by deserialization 
[org.apache.commons.lang3.builder.DiffBuilder$SDiff] In DiffBuilder.java 
SE_TRANSIENT_FIELD_NOT_RESTORED.</action>
     <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Fix Spotbugs [ERROR] Medium: The field 
org.apache.commons.lang3.builder.DiffBuilder$SDiff.rightSupplier is transient 
but isn't set by deserialization 
[org.apache.commons.lang3.builder.DiffBuilder$SDiff] In DiffBuilder.java 
SE_TRANSIENT_FIELD_NOT_RESTORED.</action>
+    <action issue="LANG-1762" type="fix" dev="ggregory" due-to="Alonso 
Gonzalez, Gary Gregory">StopWatch methods should not delegate to deprecated 
methods.</action>
     <!-- ADD -->
     <action                   type="add" dev="ggregory" due-to="Gary 
Gregory">Add Strings and refactor StringUtils.</action>
     <action issue="LANG-1747" type="add" dev="ggregory" due-to="Oliver B. 
Fischer, Gary Gregory">Add StopWatch.run([Failable]Runnable) and 
get([Failable]Supplier).</action>
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 e34542a46..e726690e5 100644
--- a/src/main/java/org/apache/commons/lang3/time/StopWatch.java
+++ b/src/main/java/org/apache/commons/lang3/time/StopWatch.java
@@ -410,7 +410,10 @@ public class StopWatch {
      * @since 3.16.0
      */
     public Instant getStartInstant() {
-        return Instant.ofEpochMilli(getStartTime());
+        if (runningState == State.UNSTARTED) {
+            throw new IllegalStateException("Stopwatch has not been started");
+        }
+        return startInstant;
     }
 
     /**
@@ -423,11 +426,7 @@ public class StopWatch {
      */
     @Deprecated
     public long getStartTime() {
-        if (runningState == State.UNSTARTED) {
-            throw new IllegalStateException("Stopwatch has not been started");
-        }
-        // stopTimeNanos stores System.nanoTime() for elapsed time
-        return startInstant.toEpochMilli();
+        return getStartInstant().toEpochMilli();
     }
 
     /**
@@ -438,7 +437,10 @@ public class StopWatch {
      * @since 3.16.0
      */
     public Instant getStopInstant() {
-        return Instant.ofEpochMilli(getStopTime());
+        if (runningState == State.UNSTARTED) {
+            throw new IllegalStateException("Stopwatch has not been started");
+        }
+        return stopInstant;
     }
 
     /**
@@ -451,11 +453,8 @@ public class StopWatch {
      */
     @Deprecated
     public long getStopTime() {
-        if (runningState == State.UNSTARTED) {
-            throw new IllegalStateException("Stopwatch has not been started");
-        }
         // stopTimeNanos stores System.nanoTime() for elapsed time
-        return stopInstant.toEpochMilli();
+        return getStopInstant().toEpochMilli();
     }
 
     /**

Reply via email to