You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by Dmitriy Brashevets <Dm...@united-security-providers.ch> on 2020/01/14 15:55:12 UTC

RE: Changes in equals and hashCode contract

Hi Francesco and other Devs.

I created an issue in Jira https://issues.apache.org/jira/projects/SYNCOPE/issues/SYNCOPE-1533.
I would like to have the previous behavior of equals and hashCode methods for these models ASAP:

1.org.apache.syncope.common.lib.to.AccessTokenTO
2.org.apache.syncope.common.lib.to.AnyTypeTO
3.org.apache.syncope.common.lib.to.ConnInstanceTO
4.org.apache.syncope.common.lib.to.ConnPoolConfTO
5.org.apache.syncope.common.lib.to.DomainTO
6.org.apache.syncope.common.lib.to.ItemTO
7.org.apache.syncope.common.lib.to.MailTemplateTO
8.org.apache.syncope.common.lib.to.MappingTO
9.org.apache.syncope.common.lib.to.OrgUnitTO
10.org.apache.syncope.common.lib.to.ProvisionTO
11.org.apache.syncope.common.lib.to.RealmTO
12.org.apache.syncope.common.lib.to.ResourceTO
13.org.apache.syncope.common.lib.to.RoleTO
14.org.apache.syncope.common.rest.api.beans.AbstractQuery
15.org.apache.syncope.common.rest.api.beans.AnyQuery
16.org.apache.syncope.common.rest.api.beans.ExecQuery
17.org.apache.syncope.common.rest.api.beans.ExecuteQuery
18.org.apache.syncope.common.rest.api.beans.SchemaQuery

I already create the PR for the models listed above in the PR.

Kind Regards,
Dmitriy Brashevets

-----Original Message-----
From: Francesco Chicchiriccò <il...@apache.org> 
Sent: Friday, December 27, 2019 7:31 PM
To: dev@syncope.apache.org
Subject: Re: Changes in equals and hashCode contract

On 24/12/19 13:41, Dmitriy Brashevets wrote:
>
> Hi Dev Team.
>
>  
>
> In Syncope 2_0_X branch all models that extend the 
> /org.apache.syncope.common.lib.AbstractBaseBean /previously used
>
> /org.apache.commons.lang3.builder.EqualsBuilder#reflectionEquals() /and/org.apache.commons.lang3.builder.HashCodeBuilder#reflectionHashCode() / in the contract of Object#equals and Object#hashCode methods.
>
>  
>
> Starting from 2_1_X the equals and hashCode contract has changed and is declared explicitly in each model.
>
>  
>
> I see that it was removed to fix the performance: https://issues.apache.org/jira/browse/SYNCOPE-1392 <https://issues.apache.org/jira/browse/SYNCOPE-1392>.
>
> Do you have any charts or diagrams that can demonstrate how the performance was improved?
>
>  
>
> We widely use the *syncope-client-lib* in our code and models from this library. And I’m afraid of that we can potentially have issues in our app, because the contract has changed.
>
Hi Dmitriy,
you can find a whole set of articles / comments / questions / commits on the Internet about performance troubles with reflection-based builders from Apache Commons Lang.

Still, we don't have any comparison for the specific change of removing such builders in favor to their non-reflective counterparts.

If your code is just  depending on syncope-client-lib, then no changes are expected on your side, as all required methods were changed upstream.

If your code is instead extending classes from syncope-client-lib, then you'll have to provide equals() / hashcode() (and possibly toString() as well) methods to your classes, according to the parent-child pattern as shown by [1][2], for example.

Hope this clarifies.
Regards.

[1] https://github.com/apache/syncope/blob/2_1_X/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java#L124-L133
[2] https://github.com/apache/syncope/blob/2_1_X/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java#L147-L155

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail http://home.apache.org/~ilgrosso/