[
https://issues.apache.org/jira/browse/LANG-872?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13585068#comment-13585068
]
Duncan Jones commented on LANG-872:
-----------------------------------
{quote}
So {{append(Object, Object)}} should be fixed and not {{append(Object[],
Object[])}}.
{quote}
I don't think {{append(Object, Object)}} should be returning true for a
{{String[]}} and a {{Object[]}}, because {{aArray.equals(bArray)}} is {{false}}.
Perhaps the Javadocs should change to make it clear the array comparison is
contents-based only?
> EqualsBuilder methods append(Object[],Object[]) and append(Object,Object)
> treats array class dirrerently
> --------------------------------------------------------------------------------------------------------
>
> Key: LANG-872
> URL: https://issues.apache.org/jira/browse/LANG-872
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.builder.*
> Affects Versions: 2.6, 3.1
> Reporter: Algirdas Raščius
> Priority: Minor
> Attachments: commons-lang3-LANG-872.patch
>
>
> Method {{EqualsBuilder.append(Object[],Object[])}} ignores classes of passed
> arrays and returns true if contents of both arrays are equal.
> Method {{EqualsBuilder.append(Object,Object)}} returns false immediately if
> types of passed array arguments are different.
> For example:
> {code}
> public void testEqualsArrays() {
> Object[] aArray = new Object[] {"Value"};
> Object[] bArray = new String[] {"Value"};
> boolean compareAsArrays = new EqualsBuilder().append(aArray,
> bArray).isEquals();
> // compareAsArrays is true
> Object aObj = aArray;
> Object bObj = bArray;
> boolean compareAsObjects = new EqualsBuilder().append(aObj,
> bObj).isEquals();
> // compareAsObjects is false
> assertTrue(compareAsArrays == compareAsObjects); //Fails
> }
> {code}
> Results of both methods should be consistent.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira