You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/01/25 12:33:55 UTC

(commons-lang) branch master updated (91b536e4f -> 3f803b8bf)

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

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


    from 91b536e4f Javadoc
     new c9a185d6e Add RecursiveToStringStyleTest.testPrimitiveWrapperArray()
     new 3f803b8bf Call Object.getClass() once

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/lang3/builder/RecursiveToStringStyle.java       |  7 ++++---
 .../commons/lang3/builder/RecursiveToStringStyleTest.java   | 13 +++++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)


(commons-lang) 01/02: Add RecursiveToStringStyleTest.testPrimitiveWrapperArray()

Posted by gg...@apache.org.
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

commit c9a185d6ef08beb5cc5c35aa9369a9a46f3199a2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 25 07:27:25 2026 -0500

    Add RecursiveToStringStyleTest.testPrimitiveWrapperArray()
---
 .../commons/lang3/builder/RecursiveToStringStyleTest.java   | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java
index 3267d8fc5..2f73484fa 100644
--- a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java
@@ -162,4 +162,17 @@ void testPerson() {
                      new ReflectionToStringBuilder(p, new RecursiveToStringStyle()).toString());
     }
 
+    @Test
+    void testPrimitiveWrapperArray() {
+        assertEquals(baseStr + "[{<null>,5,{3,6}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Character[] { '3', '6' } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{3,6}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Long[] { 3L, 6L } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{3,6}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Integer[] { 3, 6 } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{3,6}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Short[] { 3, 6 } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{3,6}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Byte[] { 3, 6 } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{3.0,6.0}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Float[] { 3f, 6f } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{3.0,6.0}}]", new ToStringBuilder(base).append(new Object[] { null, base, new Double[] { 3d, 6d } }).toString());
+        assertEquals(baseStr + "[{<null>,5,{true,false}}]",
+                new ToStringBuilder(base).append(new Object[] { null, base, new Boolean[] { true, false } }).toString());
+    }
+
 }


(commons-lang) 02/02: Call Object.getClass() once

Posted by gg...@apache.org.
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

commit 3f803b8bf78602c9464b2d01023634e32df1c388
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 25 07:31:16 2026 -0500

    Call Object.getClass() once
---
 .../org/apache/commons/lang3/builder/RecursiveToStringStyle.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java
index c8bf3fc63..15968eb12 100644
--- a/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java
+++ b/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java
@@ -87,9 +87,10 @@ protected void appendDetail(final StringBuffer buffer, final String fieldName, f
 
     @Override
     public void appendDetail(final StringBuffer buffer, final String fieldName, final Object value) {
-        if (!ClassUtils.isPrimitiveWrapper(value.getClass()) &&
-            !String.class.equals(value.getClass()) &&
-            accept(value.getClass())) {
+        final Class<? extends Object> clazz = value.getClass();
+        if (!ClassUtils.isPrimitiveWrapper(clazz) &&
+            !String.class.equals(clazz) &&
+            accept(clazz)) {
             buffer.append(ReflectionToStringBuilder.toString(value, this));
         } else {
             super.appendDetail(buffer, fieldName, value);