diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 4d8aa008519..9ad14108be6 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -77,6 +77,7 @@ The type attribute can be add,update,fix,remove. Undeprecate ObjectUtils.toString(Object). 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. 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. + StopWatch methods should not delegate to deprecated methods. Add Strings and refactor StringUtils. Add StopWatch.run([Failable]Runnable) and get([Failable]Supplier). 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 e34542a4681..e726690e568 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 long getSplitTime() { * @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 Instant getStartInstant() { */ @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 long getStartTime() { * @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 Instant getStopInstant() { */ @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(); } /**