diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6a22895f9..9f52a9b87 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. + MultilineRecursiveToStringStyle StackOverflowError when object is an array Increase test coverage of ToStringBuilder class to 100% Add a method in StringUtils to extract only digits out of input string Implement HashSetvBitSetTest using JMH diff --git a/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java index df82787f8..7c0375a33 100644 --- a/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java @@ -138,11 +138,11 @@ public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle { protected void reflectionAppendArrayDetail(final StringBuffer buffer, final String fieldName, final Object array) { spaces += INDENT; resetIndent(); - super.appendDetail(buffer, fieldName, array); + super.reflectionAppendArrayDetail(buffer, fieldName, array); spaces -= INDENT; resetIndent(); } - + @Override protected void appendDetail(final StringBuffer buffer, final String fieldName, final long[] array) { spaces += INDENT; diff --git a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java index daf2881f1..e3a87f6de 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java @@ -17,7 +17,7 @@ package org.apache.commons.lang3.builder; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; @@ -200,6 +200,20 @@ public class MultilineRecursiveToStringStyleTest { + "]"; assertEquals(exp, toString(wa)); } + + + @Test + public void testLANG1319() throws Exception { + final String[] stringArray = {"1", "2"}; + + final String exp = getClassPrefix(stringArray) + "[" + BR + + " {" + BR + + " 1," + BR + + " 2" + BR + + " }" + BR + + "]"; + assertEquals(exp, toString(stringArray)); + } private String getClassPrefix(final Object object) { return object.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(object));