You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ryan Wisnesky (JIRA)" <ji...@apache.org> on 2017/11/12 07:59:00 UTC

[jira] [Created] (LANG-1368) HashCodeBuilder.append incorrect behavior with chains of nulls

Ryan Wisnesky created LANG-1368:
-----------------------------------

             Summary: HashCodeBuilder.append incorrect behavior with chains of nulls
                 Key: LANG-1368
                 URL: https://issues.apache.org/jira/browse/LANG-1368
             Project: Commons Lang
          Issue Type: Bug
            Reporter: Ryan Wisnesky
            Priority: Minor


I have a 7-way choice/sum/variant class, so that 6 of its 7 fields are null in each object of that class.  When using HashCodeBuilder's reflective hashCode, a 10k line java project works correctly.  When using HashCodeBuilder.append instead, sequential calls to append with a null argument cause the returned hashCode to be inconsistent with EqualsBuilder.  Correct behavior can be restored by appending a dummy non-null field initially:

	new HashCodeBuilder()
					.append(true) //bad return value without this dummy call
					.append(chc1)
...
					.append(chc7)
					.toHashCode();
	



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)