You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2017/05/11 14:00:10 UTC

[2/3] lucene-solr:branch_6x: LUCENE-7817: pass cached query to onQueryCache instead of null

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

Closes #199


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4465e265
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4465e265
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4465e265

Branch: refs/heads/branch_6x
Commit: 4465e265d90f701f61f9e2cc8eb303a4515c4764
Parents: 376d764
Author: ChristophKaser <Ch...@users.noreply.github.com>
Authored: Thu May 11 15:53:51 2017 +0200
Committer: Adrien Grand <jp...@gmail.com>
Committed: Thu May 11 15:57:18 2017 +0200

----------------------------------------------------------------------
 lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java   | 2 +-
 .../core/src/test/org/apache/lucene/search/TestLRUQueryCache.java  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4465e265/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
index c48bdbe..d64bea1 100644
--- a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
+++ b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
@@ -297,7 +297,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
     try {
       Query singleton = uniqueQueries.putIfAbsent(query, query);
       if (singleton == null) {
-        onQueryCache(singleton, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + ramBytesUsed(query));
+        onQueryCache(query, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + ramBytesUsed(query));
       } else {
         query = singleton;
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4465e265/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
index 40ff386..571d72d 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
@@ -657,12 +657,14 @@ public class TestLRUQueryCache extends LuceneTestCase {
       @Override
       protected void onQueryCache(Query query, long ramBytesUsed) {
         super.onQueryCache(query, ramBytesUsed);
+        assertNotNull("cached query is null", query);
         ramBytesUsage.addAndGet(ramBytesUsed);
       }
 
       @Override
       protected void onQueryEviction(Query query, long ramBytesUsed) {
         super.onQueryEviction(query, ramBytesUsed);
+        assertNotNull("evicted query is null", query);
         ramBytesUsage.addAndGet(-ramBytesUsed);
       }