From c68285bb3392665827595ac408a5fad828b0351f Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Wed, 7 Jun 2017 19:24:52 +1200 Subject: [PATCH] Make the var a constant, and add comments --- .../apache/commons/lang3/builder/ToStringBuilderTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java index c49426db3..39dcd376c 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -36,7 +36,8 @@ import org.junit.Test; */ public class ToStringBuilderTest { - private final Integer arraylistInitialCapacity = Integer.valueOf(10); + // See LANG-1337 for more. + private static final int ARRAYLIST_INITIAL_CAPACITY = 10; private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); @@ -317,7 +318,8 @@ public class ToStringBuilderTest { // representation different for IBM JDK 1.6.0, LANG-727 assumeFalse("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION)); assumeFalse("Oracle Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".compareTo(SystemUtils.JAVA_SPECIFICATION_VERSION) < 0); - final List list = new ArrayList<>(arraylistInitialCapacity); + // LANG-1337 without this, the generated string can differ depending on the JVM version/vendor + final List list = new ArrayList<>(ARRAYLIST_INITIAL_CAPACITY); final String baseString = this.toBaseString(list); final String expectedWithTransients = baseString + "[elementData={,,,,,,,,,},size=0,modCount=0]"; final String toStringWithTransients = ToStringBuilder.reflectionToString(list, null, true);