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 bd247e45f Use String.format()
bd247e45f is described below

commit bd247e45f3edf3d9670398aae63588f2057107ca
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Mar 17 09:32:07 2026 -0400

    Use String.format()
---
 src/main/java/org/apache/commons/lang3/RandomStringUtils.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java 
b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
index 1e42a7d15..4d91b8418 100644
--- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
@@ -258,7 +258,7 @@ public static String random(int count, int start, int end, 
final boolean letters
             return StringUtils.EMPTY;
         }
         if (count < 0) {
-            throw new IllegalArgumentException("Requested random string length 
" + count + " is less than 0.");
+            throw new IllegalArgumentException(String.format("Requested random 
string length %,d is less than 0.", end));
         }
         if (chars != null && chars.length == 0) {
             throw new IllegalArgumentException("The chars array must not be 
empty");
@@ -273,7 +273,7 @@ public static String random(int count, int start, int end, 
final boolean letters
                 start = ' ';
             }
         } else if (end <= start) {
-            throw new IllegalArgumentException("Parameter end (" + end + ") 
must be greater than start (" + start + ")");
+            throw new IllegalArgumentException(String.format("Parameter end 
(%,d) must be greater than start (%,d)", end, start));
         } else if (start < 0 || end < 0) {
             throw new IllegalArgumentException("Character positions MUST be >= 
0");
         }
@@ -293,8 +293,9 @@ public static String random(int count, int start, int end, 
final boolean letters
                 return random(count, 0, 0, false, false, ALPHANUMERICAL_CHARS, 
random);
             }
             if (digits && end <= ASCII_0 || letters && end <= ASCII_A) {
-                throw new IllegalArgumentException("Parameter end (" + end + 
") must be greater than (" + ASCII_0 + ") for generating digits "
-                        + "or greater than (" + ASCII_A + ") for generating 
letters.");
+                throw new IllegalArgumentException(
+                        String.format("Parameter end (%,d) must be greater 
than (%,d) for generating digits or greater than (%,d) for generating letters.",
+                                end, ASCII_0, ASCII_A));
             }
             // Optimize start and end when filtering by letters and/or numbers:
             // The range provided may be too large since we filter anyway 
afterward.

Reply via email to