Skip to content

Commit

Permalink
[LANG-1762] StopWatch methods should not delegate to deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jan 14, 2025
1 parent b965e97 commit f5ab41f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/org/apache/commons/lang3/time/StopWatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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();
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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();
}

/**
Expand Down

0 comments on commit f5ab41f

Please sign in to comment.