Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not scramble classes without attributes #101

Closed
GoogleCodeExporter opened this issue Mar 29, 2015 · 5 comments
Closed

do not scramble classes without attributes #101

GoogleCodeExporter opened this issue Mar 29, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. write a class without attributes
2. (transiently) reference that class from another class
3. use EqualsBuilder.reflectionEquals on second class
3. execute equalsverifier on second class

equalsverifier now tries to scramble the second class and all its references. 
It fails since the first class cannot be scrambled since it has no attributes. 
It fails with IllegalArgumentException("red equals black") in 
PrefabValues.put() line 55

I would expect equalsverifier when scrambling to either ignore transient 
references (like EqualsBuilder.reflectionEquals) or to ignore referenced 
classes where red equals black

Original issue reported on code.google.com by [email protected] on 31 Dec 2014 at 5:15

@GoogleCodeExporter
Copy link
Author

Hi,

This is essentially the same issue as Issue 46, so I'll mark it as a duplicate.

First of all, I'm not sure if you meant 'transient' or 'transitive'. Both 
EqualsVerifier and EqualsBuilder have options to deal with transient fields 
(which should never be part of equals, BTW).

Also, there isn't really a point to have a stateless class in your equals. I 
get that reflectionEquals puts it there by default, but it really shouldn't be 
in equals. You can tell reflectionEquals to ignore this field.

Finally, I agree that the "red equals black" error message is a little 
unfortunate. I'll improve that in a next version. These cases cannot be 
ignored, though, because usually they indicate bugs that need to be fixed 
(either in your code, or in EqualsVerifier's code itself). In this case it's 
not, but this is really a corner case.

Original comment by [email protected] on 2 Jan 2015 at 12:18

  • Changed state: Duplicate
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Hi,

IMHO it is not a duplicate of Issue 46:
I ment 'transient'. Problem is that even if the reference _is_ transient and 
even if you tell EqualsVerifier to _ignore_ that field, it does not ignore it 
when _scrambling_ the class for testing with 
EqualsVerifier.forClass(<myclass>).verify()

This means that you can't use EqualsVerifier.forClass(A)... for any class A 
that references a stateless class B (B having no attributes). No matter if you 
reference B transiently or tell EqualsVerifier to ignore B (using 
allFieldsShouldBeUsedExcept())


Original comment by [email protected] on 2 Jan 2015 at 9:01

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Oh, ok, I think I see what you mean now. I'll take a look at it.

Next time though, please post a code snippet that reproduces the problem; it 
prevents miscommunications like this one, and the one in Issue 70.

Original comment by [email protected] on 4 Jan 2015 at 9:34

  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Fixed in version 1.6.

Original comment by [email protected] on 17 Jan 2015 at 4:27

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

thanks - works in my context.

Original comment by [email protected] on 25 Jan 2015 at 11:15

  • Added labels: ****
  • Removed labels: ****

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant