commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Goran Hacek <goran.ha...@gmail.com>
Subject Re: svn commit: r825151 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/NOPClosure.java
Date Thu, 15 Oct 2009 12:24:33 GMT
On Wed, Oct 14, 2009 at 19:56, sebb <sebbaz@gmail.com> wrote:
> Why not just remove the equals() and hashCode() methods?
> The defaults are just as good.

It is not the same because multiple instances of NOPClosure can exist.
This is because of serialization support.

By implementing readResolve() method which will always return INSTANCE
static member will ensure that no more then one instance of NOPClosure
exists at any given time. With this guaranty default equals() and
hashCode() will do their job as they should.

Javadoc comment on INSTANCE static member, which says "Singleton
predicate instance", is not correct because class doesn't implement
singleton pattern correctly. This would be fixed by implementing
readResolve() as previously described.

I have created a patch for this, it is in jira[1], so can someone review it?

[1] https://issues.apache.org/jira/browse/COLLECTIONS-343

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message