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

CrmLookupEntity.equals(Object) issues #3

Open
rgoldberg opened this issue May 12, 2015 · 2 comments
Open

CrmLookupEntity.equals(Object) issues #3

rgoldberg opened this issue May 12, 2015 · 2 comments

Comments

@rgoldberg
Copy link

In CrmLookupEntity.equals(Object), if o == null, you get a NullPointerException.

If ! (o instanceof CrmLookupEntity), you get a GroovyCastException

Existing code:

boolean equals(o) {
    if (this.is(o)) return true
    //if (getClass() != o.class) return false
    // TODO How can we handle Hibernate proxies here without importing org.hibernate?
    // grails.plugins.crm.order.CrmOrderStatus_$$_javassist_7
    // grails.plugins.crm.order.CrmOrderStatus

    CrmLookupEntity that = (CrmLookupEntity) o

    if (this.id != that.id) return false
    if (this.orderIndex != that.orderIndex) return false
    if (this.name != that.name) return false
    if (this.param != that.param) return false

    return true
}

The following commented line should be replaced:

    //if (getClass() != o.class) return false

by something like:

    if (o == null || getClass() != o.class) return false

or:

    if (o == null || ! getClass().isAssignableFrom(o.class)) return false

A NullPointerException will also be thrown by CrmContactAddress.equals(Object), so you should check all of the equals(Object) methods in all of the crm classes.

If you want, the following article is useful for implementing robust equals(Object) methods:

http://www.artima.com/lejava/articles/equality.html

@rgoldberg
Copy link
Author

Have you had a chance to look into this issue?

@goeh
Copy link
Owner

goeh commented Aug 26, 2015

No, not yet. I'm sorry but I'm too overloaded with client work at the moment. But I appreciate your findings in this area. I will take a look at it, but I cannot promise any dates.

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

No branches or pull requests

2 participants