directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: equals() implementation in ProtectedItem
Date Fri, 21 May 2010 06:45:16 GMT
Felix Knecht schrieb:
> Are you aware, that this [1] is an equal of collections and will return
> in most cases "false" as it is a reference comparison [2]?
> 
> Is this wanted?

I don't think that is wanted.

I checked the history. Previously we didn't use
  Collections.unmodifiableCollection( attributeTypes )
And a quick check shows that the callers of the construtor always pass
an java.util.Set.

For two Sets the equals method would work correctly, but the creation of
the unmodifyalbe collection not.

I think we have two options:
- use CollectionUtils.isEqualCollection() from commons collections, this
seems to do the right thing.
- try to change the parameter type from Collection to Set in the
constructors and use Collections.unmodifiableSet() instead.

Thoughts?

Kind Regards,
Stefan


> 
> Felix
> 
> [1]
> http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/aci/ProtectedItem.html#245
> [2]
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html#equals%28java.lang.Object%29

Mime
View raw message