Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7277

Make Query.hashCode and Query.equals abstract

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      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)?

        public int hashCode() {
          return getClass().hashCode();
        }
      
        public boolean equals(Object obj) {
          if (obj == null)
            return false;
          return getClass() == obj.getClass();
        }
      

        Attachments

        1. LUCENE-7277.patch
          205 kB
          Dawid Weiss
        2. LUCENE-7277.patch
          9 kB
          Dawid Weiss
        3. LUCENE-7277-20160518.patch
          91 kB
          Paul Elschot

          Issue Links

            Activity

              People

              • Assignee:
                dweiss Dawid Weiss
                Reporter:
                dweiss Dawid Weiss
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: