From f38cdfbf8c7f2f908b21e02c64d1003c47cf3b00 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Sat, 16 May 2009 08:26:07 +0000 Subject: [PATCH] Cloning the output from getExcludeFieldNames, adjusting the code to use the attribute directly so it doesn't pay the clone() cost every time and changing the attribute from private to protected to let subclasses retain the ability to modify the field names (if that is why a getExcludeFieldNames method existed). Document in LANG-489 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@775432 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang/builder/ReflectionToStringBuilder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java b/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java index d1b79bfb8..0658586c7 100644 --- a/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java +++ b/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java @@ -378,7 +378,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { /** * Which field names to exclude from output. Intended for fields like "password". */ - private String[] excludeFieldNames; + protected String[] excludeFieldNames; /** * The last super class to stop appending fields for. @@ -496,11 +496,11 @@ public class ReflectionToStringBuilder extends ToStringBuilder { return false; } if (Modifier.isStatic(field.getModifiers()) && !this.isAppendStatics()) { - // Rject static fields. + // Reject static fields. return false; } - if (this.getExcludeFieldNames() != null - && Arrays.binarySearch(this.getExcludeFieldNames(), field.getName()) >= 0) { + if (this.excludeFieldNames != null + && Arrays.binarySearch(this.excludeFieldNames, field.getName()) >= 0) { // Reject fields from the getExcludeFieldNames list. return false; } @@ -550,7 +550,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @return Returns the excludeFieldNames. */ public String[] getExcludeFieldNames() { - return this.excludeFieldNames; + return this.excludeFieldNames.clone(); } /**