sgup432 opened a new pull request, #16657:
URL: https://github.com/apache/lucene/pull/16657
### Description
LRUQueryCache was recently refactored(releasing in lucene 11.0) to partition
the cache, and its key structure was changed into a composite
one(QueryCacheKey).
I found out a bug in this QueryCacheKey where this compares queries by value
in `equals()` but hashes them with `System.identityHashCode(query)`, breaking
the hashCode/equals contract. For example: we cache `new
TermQuery("color","red")`, then look it up with another `new
TermQuery("color","red")`. The two are equal, but their identity hashes differ,
so the lookup checks the wrong bucket and misses even though the entry is right
there.
The PR fixes this: hash by `query.hashCode()` so it matches equals() (and
cache the composite hash to avoid its recomputation).
<!--
If this is your first contribution to Lucene, please make sure you have
reviewed the contribution guide.
https://github.com/apache/lucene/blob/main/CONTRIBUTING.md
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]