You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Sauder (JIRA)" <ji...@apache.org> on 2010/03/13 21:18:27 UTC

[jira] Updated: (LANG-606) EqualsBuilder causes StackOverflowException

     [ https://issues.apache.org/jira/browse/LANG-606?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Sauder updated LANG-606:
-------------------------------

    Attachment: EqualsBuilderCyclicalObjectReferences.patch

Attached patch should solve the issue.

I've used the same attempt used in HashCodeBuilder solving the cyclical reference issue.

Only difference is that a registry with objects pairs is used. When checking if two objects have already be compared resp. registered those two objects need to be swapped as the cyclical reference takes place when "the other object" is the "this object".

> EqualsBuilder causes StackOverflowException
> -------------------------------------------
>
>                 Key: LANG-606
>                 URL: https://issues.apache.org/jira/browse/LANG-606
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.builder.*
>    Affects Versions: 2.5
>            Reporter: Oliver Sauder
>            Priority: Minor
>         Attachments: EqualsBuilderCyclicalObjectReferences.patch
>
>
> EqualsBuilder causes StackOverflowException when comparing objects with cyclical object references.
> e,g.
> static class TestObjectReference {
> 		@SuppressWarnings("unused")
> 		private TestObjectReference reference;
>     	@SuppressWarnings("unused")
> 		private TestObject one;
>     	
>     	public TestObjectReference(int one) {
> 			this.one = new TestObject(one);
> 		}
>     	
>     	public void setObjectReference(
>     			TestObjectReference reference) {
> 			this.reference = reference;
> 		}
> 		@Override
> 		public boolean equals(Object obj) {
> 			return EqualsBuilder.reflectionEquals(this, obj);
> 		}
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.