You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Roman Puchkovskiy <ro...@blandware.com> on 2008/06/30 13:31:59 UTC

JCAConnectionRequestInfo: equals() and hashCode() are inconsistent?

Looking at JCAConnectionRequestInfo, I see that in its equals() method it
handles the comparison of SimpleCredentials as a special case.
SimpleCredentials does not override equals() method, so
JCAConnectionRequestInfo.equals() makes the comparison by hand.
But hashCode() method just delegates to Credentials' hashCode() method which
is not overridden in SimpleCredentials too. So, when you place a
JCAConnectionRequestInfo in the HashSet (or into a HashMap as a key) you
will never see hits.
This, in particular, seems to break JCR session pooling.
Is this just a bug, or there's some rationale behind such inconsistency?

Thanks in advance.
-- 
View this message in context: http://www.nabble.com/JCAConnectionRequestInfo%3A-equals%28%29-and-hashCode%28%29-are-inconsistent--tp18193632p18193632.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: JCAConnectionRequestInfo: equals() and hashCode() are inconsistent?

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Jun 30, 2008 at 7:31 AM, Roman Puchkovskiy
<ro...@blandware.com> wrote:
>
> Looking at JCAConnectionRequestInfo, I see that in its equals() method it
> handles the comparison of SimpleCredentials as a special case.
> SimpleCredentials does not override equals() method, so
> JCAConnectionRequestInfo.equals() makes the comparison by hand.
> But hashCode() method just delegates to Credentials' hashCode() method which
> is not overridden in SimpleCredentials too. So, when you place a
> JCAConnectionRequestInfo in the HashSet (or into a HashMap as a key) you
> will never see hits.
> This, in particular, seems to break JCR session pooling.
> Is this just a bug, or there's some rationale behind such inconsistency?

Have you verified that it actually does not work in a HashMap? If yes,
I would consider this as a bug, and would be happy if you could file
one at JIRA.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com