diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 17afee8a0..647ec3a62 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -52,6 +52,7 @@ The type attribute can be add,update,fix,remove. Speed up and sanitize StopWatchTest. Fix handling of non-ASCII letters and numbers in RandomStringUtils #1273. Rewrite ClassUtils.getClass(...) without recursion to avoid StackOverflowError on very long inputs. OSS-Fuzz Issue 42522972: apache-commons-text:StringSubstitutorInterpolatorFuzzer: Security exception in org.apache.commons.lang3.ClassUtils.getClass. + Remove trailing whitespace in StopWatch exception messages. 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 5b81fa94c..86eea98ca 100644 --- a/src/main/java/org/apache/commons/lang3/time/StopWatch.java +++ b/src/main/java/org/apache/commons/lang3/time/StopWatch.java @@ -578,7 +578,7 @@ public class StopWatch { */ public void resume() { if (runningState != State.SUSPENDED) { - throw new IllegalStateException("Stopwatch must be suspended to resume. "); + throw new IllegalStateException("Stopwatch must be suspended to resume."); } startTimeNanos += System.nanoTime() - stopTimeNanos; runningState = State.RUNNING; @@ -628,7 +628,7 @@ public class StopWatch { */ public void split() { if (runningState != State.RUNNING) { - throw new IllegalStateException("Stopwatch is not running. "); + throw new IllegalStateException("Stopwatch is not running."); } stopTimeNanos = System.nanoTime(); splitState = SplitState.SPLIT; @@ -645,10 +645,10 @@ public class StopWatch { */ public void start() { if (runningState == State.STOPPED) { - throw new IllegalStateException("Stopwatch must be reset before being restarted. "); + throw new IllegalStateException("Stopwatch must be reset before being restarted."); } if (runningState != State.UNSTARTED) { - throw new IllegalStateException("Stopwatch already started. "); + throw new IllegalStateException("Stopwatch already started."); } startTimeNanos = System.nanoTime(); startInstant = Instant.now(); @@ -677,7 +677,7 @@ public class StopWatch { */ public void stop() { if (runningState != State.RUNNING && runningState != State.SUSPENDED) { - throw new IllegalStateException("Stopwatch is not running. "); + throw new IllegalStateException("Stopwatch is not running."); } if (runningState == State.RUNNING) { stopTimeNanos = System.nanoTime(); @@ -697,7 +697,7 @@ public class StopWatch { */ public void suspend() { if (runningState != State.RUNNING) { - throw new IllegalStateException("Stopwatch must be running to suspend. "); + throw new IllegalStateException("Stopwatch must be running to suspend."); } stopTimeNanos = System.nanoTime(); stopInstant = Instant.now(); @@ -749,7 +749,7 @@ public class StopWatch { */ public void unsplit() { if (splitState != SplitState.SPLIT) { - throw new IllegalStateException("Stopwatch has not been split. "); + throw new IllegalStateException("Stopwatch has not been split."); } splitState = SplitState.UNSPLIT; }