atris commented on a change in pull request #815: LUCENE-8213: Introduce 
Asynchronous Caching in LRUQueryCache
URL: https://github.com/apache/lucene-solr/pull/815#discussion_r329308954
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
 ##########
 @@ -867,12 +881,25 @@ public BulkScorer bulkScorer(LeafReaderContext context) 
throws IOException {
 
       if (docIdSet == null) {
         if (policy.shouldCache(in.getQuery())) {
+          boolean performSynchronousCaching = !(executor != null);
           // If asynchronous caching is requested, perform the same and return
           // the uncached iterator
-          if (executor != null) {
-            cacheAsynchronously(context, cacheHelper);
-            return in.bulkScorer(context);
-          } else {
+          if (!performSynchronousCaching) {
+            try {
+              cacheAsynchronously(context, cacheHelper);
+            } catch (RejectedExecutionException e) {
 
 Review comment:
   If the caller has specified a different policy -- we should not be even 
getting here. `IndexSearcher#search` API does not advertise the behaviour for 
the case if the underlying `Executor` does not have enough capacity, nor does 
it consider the size of the executor during allocation of leaves. Both of the 
above facts lead to an implicit API contract where we are expected to 
gracefully handle the case of rejected execution. In case the user wishes to 
handle the exception themselves, they are free to override the default methods 
-- similar to what we advice for other methods in `IndexSearcher`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to