diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java index b47049ca6..816206b6d 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java @@ -648,7 +648,8 @@ public class ReflectionToStringBuilder extends ToStringBuilder { if (excludeFieldNamesParam == null) { this.excludeFieldNames = null; } else { - this.excludeFieldNames = excludeFieldNamesParam.clone(); + //clone and remove nulls + this.excludeFieldNames = toNoNullStringArray(excludeFieldNamesParam); Arrays.sort(this.excludeFieldNames); } return this;