This is an automated email from the ASF dual-hosted git repository.

garydgregory 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 78de8a9aa Drop trailing empty token from splitByWholeSeparator (#1710).
78de8a9aa is described below

commit 78de8a9aa9ecb40c02888467a6514f6536f3669d
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jun 17 18:59:50 2026 +0000

    Drop trailing empty token from splitByWholeSeparator (#1710).
    
    Sort members.
---
 src/changes/changes.xml                            |  1 +
 .../org/apache/commons/lang3/StringUtilsTest.java  | 28 +++++++++++-----------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 706188314..1af01d5c6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -191,6 +191,7 @@ java.lang.NullPointerException: Cannot invoke
     <action                   type="fix" dev="ggregory" due-to="alhudz, Gary 
Gregory">Fix substringAfter(Last) for supplementary code points 
(#1707).</action>
     <action                   type="fix" dev="ggregory" due-to="alhudz, Gary 
Gregory">Strip L suffix for oversized hex literals in createNumber 
(#1712).</action>
     <action                   type="fix" dev="ggregory" due-to="alhudz, Gary 
Gregory">Fix spurious overflow in Fraction.add/subtract for coprime 
denominators (#1709).</action>
+    <action                   type="fix" dev="ggregory" due-to="alhudz, Gary 
Gregory">Drop trailing empty token from splitByWholeSeparator (#1710).</action>
     <!-- ADD -->
     <action                   type="add" dev="ggregory" due-to="Gary 
Gregory">Add JavaVersion.JAVA_27.</action>
     <action                   type="add" dev="ggregory" due-to="Gary 
Gregory">Add SystemUtils.IS_JAVA_27.</action>
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index e1ce6e1d3..9a32ce099 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -2439,20 +2439,6 @@ void testSplitByWholeString_StringStringBoolean() {
         }
     }
 
-    @ParameterizedTest
-    @CsvSource({
-        "a:b:,       :,   'a,b'",
-        "a:,         :,   a",
-        "ab-!-cd-!-, -!-, 'ab,cd'",
-    })
-    void testSplitByWholeStringDropsTrailingEmpty(final String str, final 
String separator, final String expected) {
-        final String[] expectedTokens = expected.split(",");
-        // a trailing separator must not leak an empty token (it is dropped, 
like leading and adjacent ones)
-        assertArrayEquals(expectedTokens, 
StringUtils.splitByWholeSeparator(str, separator));
-        // the preserve-all-tokens variant still keeps the trailing empty token
-        assertArrayEquals(ArrayUtils.add(expectedTokens, ""), 
StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator));
-    }
-
     @Test
     void testSplitByWholeString_StringStringBooleanInt() {
         assertArrayEquals(null, StringUtils.splitByWholeSeparator(null, ".", 
3));
@@ -2480,6 +2466,20 @@ void testSplitByWholeString_StringStringBooleanInt() {
         }
     }
 
+    @ParameterizedTest
+    @CsvSource({
+        "a:b:,       :,   'a,b'",
+        "a:,         :,   a",
+        "ab-!-cd-!-, -!-, 'ab,cd'",
+    })
+    void testSplitByWholeStringDropsTrailingEmpty(final String str, final 
String separator, final String expected) {
+        final String[] expectedTokens = expected.split(",");
+        // a trailing separator must not leak an empty token (it is dropped, 
like leading and adjacent ones)
+        assertArrayEquals(expectedTokens, 
StringUtils.splitByWholeSeparator(str, separator));
+        // the preserve-all-tokens variant still keeps the trailing empty token
+        assertArrayEquals(ArrayUtils.add(expectedTokens, ""), 
StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator));
+    }
+
     @Test
     void testSplitPreserveAllTokens_String() {
         assertNull(StringUtils.splitPreserveAllTokens(null));

Reply via email to