[
https://issues.apache.org/jira/browse/LUCENE-7277?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dawid Weiss updated LUCENE-7277:
--------------------------------
Attachment: LUCENE-7277.patch
So I'm thinking about something like this (it's not a complete patch, but given
an idea what the pattern looks like).
Looking at the current implementation only convinces me that the delegation
pattern to superclass makes little sense -- every query subclass is typically
different, so it really should implement these correctly for its own case.
I also opted to remove Class.hashCode() from hashCode's mixing functions, even
if there are collisions they should be infrequent and easily solvable with
equals(), so I don't see the point of computing it. But it's a matter of taste.
> Make Query.hashCode and Query.equals abstract
> ---------------------------------------------
>
> Key: LUCENE-7277
> URL: https://issues.apache.org/jira/browse/LUCENE-7277
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Dawid Weiss
> Assignee: Dawid Weiss
> Priority: Trivial
> Attachments: LUCENE-7277.patch
>
>
> Custom subclasses of the Query class have the default implementation of
> hashCode/equals that make all instances of the subclass equal. If somebody
> doesn't know this it can be pretty tricky to debug with IndexSearcher's query
> cache on.
> Is there any rationale for declaring it this way instead of making those
> methods abstract (and enforcing their proper implementation in a subclass)?
> {code}
> public int hashCode() {
> return getClass().hashCode();
> }
> public boolean equals(Object obj) {
> if (obj == null)
> return false;
> return getClass() == obj.getClass();
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]