[ 
https://issues.apache.org/jira/browse/LUCENE-10431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17501292#comment-17501292
 ] 

ASF subversion and git services commented on LUCENE-10431:
----------------------------------------------------------

Commit 5e539bc50d92c0003e4310d9034aec5af353f1f8 in lucene's branch 
refs/heads/branch_9x from Alan Woodward
[ https://gitbox.apache.org/repos/asf?p=lucene.git;h=5e539bc ]

LUCENE-10431: Don't include rewriteMethod in MTQ hash calculation (#727)

BooleanQuery assumes that its children's hashcodes are stable, and has some
assertions to this effect. This did not apply to MultiTermQuery, which has a
mutable RewriteMethod member variable that was included in its hash calculation.
Changing the rewrite method would change the hash, leading to assertion failures
being tripped. This commit removes rewriteMethod from the hash calculation,
meaning that the hashcode will be stable even under mutability.

> AssertionError in BooleanQuery.hashCode()
> -----------------------------------------
>
>                 Key: LUCENE-10431
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10431
>             Project: Lucene - Core
>          Issue Type: Bug
>    Affects Versions: 8.11.1
>            Reporter: Michael Bien
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Hello devs,
> the constructor of BooleanQuery can under some circumstances trigger a hash 
> code computation before "clauseSets" is fully filled. Since BooleanClause is 
> using its query field for the hash code too, it can happen that the "wrong" 
> hash code is stored, since adding the clause to the set triggers its 
> hashCode().
> If assertions are enabled the check in BooleanQuery, which recomputes the 
> hash code, will notice it and throw an error.
> exception:
> {code:java}
> java.lang.AssertionError
>     at org.apache.lucene.search.BooleanQuery.hashCode(BooleanQuery.java:614)
>     at java.base/java.util.Objects.hashCode(Objects.java:103)
>     at java.base/java.util.HashMap$Node.hashCode(HashMap.java:298)
>     at java.base/java.util.AbstractMap.hashCode(AbstractMap.java:527)
>     at org.apache.lucene.search.Multiset.hashCode(Multiset.java:119)
>     at java.base/java.util.EnumMap.entryHashCode(EnumMap.java:717)
>     at java.base/java.util.EnumMap.hashCode(EnumMap.java:709)
>     at java.base/java.util.Arrays.hashCode(Arrays.java:4498)
>     at java.base/java.util.Objects.hash(Objects.java:133)
>     at 
> org.apache.lucene.search.BooleanQuery.computeHashCode(BooleanQuery.java:597)
>     at org.apache.lucene.search.BooleanQuery.hashCode(BooleanQuery.java:611)
>     at java.base/java.util.HashMap.hash(HashMap.java:340)
>     at java.base/java.util.HashMap.put(HashMap.java:612)
>     at org.apache.lucene.search.Multiset.add(Multiset.java:82)
>     at org.apache.lucene.search.BooleanQuery.<init>(BooleanQuery.java:154)
>     at org.apache.lucene.search.BooleanQuery.<init>(BooleanQuery.java:42)
>     at 
> org.apache.lucene.search.BooleanQuery$Builder.build(BooleanQuery.java:133)
> {code}
> I noticed this while trying to upgrade the NetBeans maven indexer modules 
> from lucene 5.x to 8.x https://github.com/apache/netbeans/pull/3558



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to