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-text.git


The following commit(s) were added to refs/heads/master by this push:
     new aa7ce204 [TEXT-239] TextStringBuilder.append(char[], int, int) uses 
wrong variable in exception message #735
aa7ce204 is described below

commit aa7ce204885d80b5c8d66e2b7f81401e9b2883e8
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jan 28 06:18:09 2026 -0500

    [TEXT-239] TextStringBuilder.append(char[], int, int) uses wrong
    variable in exception message #735
    
    Use longer lines
    Keep test methods in AB order
---
 src/changes/changes.xml                            |  1 +
 .../org/apache/commons/text/StrBuilderTest.java    | 28 ++++++++--------------
 .../apache/commons/text/TextStringBuilderTest.java | 28 ++++++++--------------
 3 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9ce69c48..4bfbe4f8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
     <release version="1.15.1" date="YYYY-MM-DD" description="This is a feature 
and maintenance release. Java 8 or later is required.">
       <!-- FIX -->
       <action type="fix" dev="ggregory" due-to="Dominik Stadler, Gary 
Gregory">Improve test coverage #732.</action>
+      <action type="fix" dev="ggregory" issue="TEXT-239" due-to="Dominik 
Stadler, Gary Gregory">TextStringBuilder.append(char[], int, int) uses wrong 
variable in exception message #735.</action>
       <!-- ADD -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
org.apache.commons:commons-parent from 93 to 96.</action>
diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java 
b/src/test/java/org/apache/commons/text/StrBuilderTest.java
index 5edfec6f..6d7de7e5 100644
--- a/src/test/java/org/apache/commons/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java
@@ -834,6 +834,16 @@ class StrBuilderTest {
         assertTrue(sb1.equalsIgnoreCase(sb2));
     }
 
+    @Test
+    void testErrorMessageShowsCorrectVariable() {
+        final StrBuilder sb = new StrBuilder("Hello");
+        final char[] chars = { 'a', 'b', 'c' };
+        StringIndexOutOfBoundsException ex = 
assertThrows(StringIndexOutOfBoundsException.class, () -> sb.append(chars, 1, 
4));
+        assertTrue(ex.getMessage().contains("length: 4"));
+        ex = assertThrows(StringIndexOutOfBoundsException.class, () -> 
sb.append(chars, 7, 3));
+        assertTrue(ex.getMessage().contains("startIndex: 7"));
+    }
+
     @Test
     void testGetChars() {
         final StrBuilder sb = new StrBuilder();
@@ -2016,22 +2026,4 @@ class StrBuilderTest {
         sb.clear().append("a b c");
         assertEquals("a b c", sb.trim().toString());
     }
-
-    @Test
-    void testErrorMessageShowsCorrectVariable() {
-        final StrBuilder sb = new StrBuilder("Hello");
-        final char[] chars = {'a', 'b', 'c'};
-
-        StringIndexOutOfBoundsException ex = assertThrows(
-                StringIndexOutOfBoundsException.class,
-                () -> sb.append(chars, 1, 4)
-        );
-        assertTrue(ex.getMessage().contains("length: 4"));
-
-        ex = assertThrows(
-                StringIndexOutOfBoundsException.class,
-                () -> sb.append(chars, 7, 3)
-        );
-        assertTrue(ex.getMessage().contains("startIndex: 7"));
-    }
 }
diff --git a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java 
b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
index 1efbf251..649fc4ea 100644
--- a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
@@ -989,6 +989,16 @@ class TextStringBuilderTest {
         // TextStringBuilder("title".toUpperCase(turkish))));
     }
 
+    @Test
+    void testErrorMessageShowsCorrectVariable() {
+        final TextStringBuilder sb = new TextStringBuilder("Hello");
+        final char[] chars = { 'a', 'b', 'c' };
+        StringIndexOutOfBoundsException ex = 
assertThrows(StringIndexOutOfBoundsException.class, () -> sb.append(chars, 1, 
4));
+        assertTrue(ex.getMessage().contains("length: 4"));
+        ex = assertThrows(StringIndexOutOfBoundsException.class, () -> 
sb.append(chars, 7, 3));
+        assertTrue(ex.getMessage().contains("startIndex: 7"));
+    }
+
     @Test
     void testGetChars() {
         final TextStringBuilder sb = new TextStringBuilder();
@@ -2392,22 +2402,4 @@ class TextStringBuilderTest {
         assertThrows(IllegalArgumentException.class, () -> 
TextStringBuilder.wrap("abc".toCharArray(), -1));
         assertThrows(IllegalArgumentException.class, () -> 
TextStringBuilder.wrap(ArrayUtils.EMPTY_CHAR_ARRAY, 1));
     }
-
-    @Test
-    void testErrorMessageShowsCorrectVariable() {
-        final TextStringBuilder sb = new TextStringBuilder("Hello");
-        final char[] chars = {'a', 'b', 'c'};
-
-        StringIndexOutOfBoundsException ex = assertThrows(
-                StringIndexOutOfBoundsException.class,
-                () -> sb.append(chars, 1, 4)
-        );
-        assertTrue(ex.getMessage().contains("length: 4"));
-
-        ex = assertThrows(
-                StringIndexOutOfBoundsException.class,
-                () -> sb.append(chars, 7, 3)
-        );
-        assertTrue(ex.getMessage().contains("startIndex: 7"));
-    }
 }

Reply via email to