LUCENE-7817: pass cached query to onQueryCache instead of null

Closes #199
This commit is contained in:
ChristophKaser 2017-05-11 15:53:51 +02:00 committed by Adrien Grand
parent 30a50eaf83
commit fb56948e70
2 changed files with 3 additions and 1 deletions

View File

@ -298,7 +298,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
try { try {
Query singleton = uniqueQueries.putIfAbsent(query, query); Query singleton = uniqueQueries.putIfAbsent(query, query);
if (singleton == null) { if (singleton == null) {
onQueryCache(singleton, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + ramBytesUsed(query)); onQueryCache(query, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + ramBytesUsed(query));
} else { } else {
query = singleton; query = singleton;
} }

View File

@ -660,12 +660,14 @@ public class TestLRUQueryCache extends LuceneTestCase {
@Override @Override
protected void onQueryCache(Query query, long ramBytesUsed) { protected void onQueryCache(Query query, long ramBytesUsed) {
super.onQueryCache(query, ramBytesUsed); super.onQueryCache(query, ramBytesUsed);
assertNotNull("cached query is null", query);
ramBytesUsage.addAndGet(ramBytesUsed); ramBytesUsage.addAndGet(ramBytesUsed);
} }
@Override @Override
protected void onQueryEviction(Query query, long ramBytesUsed) { protected void onQueryEviction(Query query, long ramBytesUsed) {
super.onQueryEviction(query, ramBytesUsed); super.onQueryEviction(query, ramBytesUsed);
assertNotNull("evicted query is null", query);
ramBytesUsage.addAndGet(-ramBytesUsed); ramBytesUsage.addAndGet(-ramBytesUsed);
} }