lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dawid Weiss (JIRA)" <>
Subject [jira] [Updated] (LUCENE-7277) Make Query.hashCode and Query.equals abstract
Date Mon, 23 May 2016 07:27:12 GMT


Dawid Weiss updated LUCENE-7277:
    Attachment: LUCENE-7277.patch

Updated patch. Tests pass.

This is a rather large patch already, so I didn't want to make it any larger, leaving some
hashCode implementation the way they were implemented (although some of them look rather odd).

I think we should put this in as soon as possible, it really is a nice cleanup over various
forms and shapes of the hashCode/equals implementation encountered in the code.

As a separate issue, I'd ban the use of getClass().hashCode() entirely (it is still used in
a number of places) as it changes from execution to execution and can cause problems with

> Make Query.hashCode and Query.equals abstract
> ---------------------------------------------
>                 Key: LUCENE-7277
>                 URL:
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Dawid Weiss
>            Assignee: Dawid Weiss
>            Priority: Trivial
>         Attachments: LUCENE-7277-20160518.patch, LUCENE-7277.patch, 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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message