[
https://issues.apache.org/jira/browse/LUCENE-7277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15290662#comment-15290662
]
Dawid Weiss commented on LUCENE-7277:
-------------------------------------
Hmm..., try it:
{code}
git co 4bc3477fbf9be688c14bbb07f5982d5f4b615591
git apply LUCENE-7277-20160518.patch
{code}
results in errors for me:
{code}
error: patch failed:
lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java:421
error: lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java: patch
does not apply
error: patch failed:
lucene/core/src/java/org/apache/lucene/search/MatchNoDocsQuery.java:25
error: lucene/core/src/java/org/apache/lucene/search/MatchNoDocsQuery.java:
patch does not apply
error: patch failed:
lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java:315
error: lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java:
patch does not apply
error: patch failed:
lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java:230
error: lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java:
patch does not apply
error: patch failed: lucene/core/src/java/org/apache/lucene/search/Query.java:74
error: lucene/core/src/java/org/apache/lucene/search/Query.java: patch does not
apply
error: patch failed:
lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java:153
error: lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java:
patch does not apply
error: patch failed:
lucene/core/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java:102
error:
lucene/core/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java:
patch does not apply
error: patch failed:
lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java:299
error:
lucene/join/src/java/org/apache/lucene/search/join/PointInSetIncludingScoreQuery.java:
patch does not apply
error: patch failed:
lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java:475
error:
lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java:
patch does not apply
error: patch failed:
lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java:420
error:
lucene/queryparser/src/java/org/apache/lucene/queryparser/complexPhrase/ComplexPhraseQueryParser.java:
patch does not apply
error: patch failed:
lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java:67
error: lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java:
patch does not apply
error: patch failed:
solr/core/src/java/org/apache/solr/search/QueryWrapperFilter.java:89
error: solr/core/src/java/org/apache/solr/search/QueryWrapperFilter.java: patch
does not apply
{code}
bq. In case replacing getClass().hashCode() by something like
getClass().getName().hashCode() is preferred for easier testing, it would
probably be better to add that in a companion method to sameClassAs(), for
example classHash().
Yep, I agree. Could even be lazily initialized once, much like the hash in
Boolean query.
bq. As to AssertionError or UOE, do we have a standard for that? I have seen
UOE in a few places, so I used that.
I don't think there's a standard for such things -- IllegalStateException, UOE,
RuntimeException, InternalError... all these are used to signal unreachable
code (or code that "theoretically" shouldn't execute). Not anything specific to
Lucene, the inconsistency is everywhere, in the JDK too. I prefer new
AssertionError("Reason") because this is an error (not an exception) and it
cannot be confused with legitimate exceptions thrown by the java linker (unlike
UOE)... but it's really my personal call, not a rule
bq. I would not mind rebasing the local branch to update the patch, but I'll
have very little time the coming days.
I can take over if you make that branch available somewhere (github?).
> 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-20160518.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
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]