Skip to content

Commit f5ab41f

Browse files
committed
[LANG-1762] StopWatch methods should not delegate to deprecated methods
1 parent b965e97 commit f5ab41f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ The <action> type attribute can be add,update,fix,remove.
7777
<action type="fix" dev="ggregory" due-to="Gary Gregory">Undeprecate ObjectUtils.toString(Object).</action>
7878
<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>
7979
<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>
80+
<action issue="LANG-1762" type="fix" dev="ggregory" due-to="Alonso Gonzalez, Gary Gregory">StopWatch methods should not delegate to deprecated methods.</action>
8081
<!-- ADD -->
8182
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Strings and refactor StringUtils.</action>
8283
<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>

src/main/java/org/apache/commons/lang3/time/StopWatch.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ public long getSplitTime() {
410410
* @since 3.16.0
411411
*/
412412
public Instant getStartInstant() {
413-
return Instant.ofEpochMilli(getStartTime());
413+
if (runningState == State.UNSTARTED) {
414+
throw new IllegalStateException("Stopwatch has not been started");
415+
}
416+
return startInstant;
414417
}
415418

416419
/**
@@ -423,11 +426,7 @@ public Instant getStartInstant() {
423426
*/
424427
@Deprecated
425428
public long getStartTime() {
426-
if (runningState == State.UNSTARTED) {
427-
throw new IllegalStateException("Stopwatch has not been started");
428-
}
429-
// stopTimeNanos stores System.nanoTime() for elapsed time
430-
return startInstant.toEpochMilli();
429+
return getStartInstant().toEpochMilli();
431430
}
432431

433432
/**
@@ -438,7 +437,10 @@ public long getStartTime() {
438437
* @since 3.16.0
439438
*/
440439
public Instant getStopInstant() {
441-
return Instant.ofEpochMilli(getStopTime());
440+
if (runningState == State.UNSTARTED) {
441+
throw new IllegalStateException("Stopwatch has not been started");
442+
}
443+
return stopInstant;
442444
}
443445

444446
/**
@@ -451,11 +453,8 @@ public Instant getStopInstant() {
451453
*/
452454
@Deprecated
453455
public long getStopTime() {
454-
if (runningState == State.UNSTARTED) {
455-
throw new IllegalStateException("Stopwatch has not been started");
456-
}
457456
// stopTimeNanos stores System.nanoTime() for elapsed time
458-
return stopInstant.toEpochMilli();
457+
return getStopInstant().toEpochMilli();
459458
}
460459

461460
/**

0 commit comments

Comments
 (0)