Procházet zdrojové kódy

Avoid holding references to SearchExecutionContext in SourceConfirmedTextQuery (#134887) (#134914)

Lucene Query objects can hang around for longer than a single search,
for example as the key in a Query cache.  This means that they should
not hold references to anything that is only expected to exist for the
duration of a single search request.

SourceConfirmedTextQuery holds a lambda to load data during query
execution.  This commit changes one of the constructor calls to avoid
capturing unnecessary references to the SearchExecutionContext, an
object which is expected to be short-lived.
Alan Woodward před 3 týdny
rodič
revize
c5eafe2872

+ 5 - 0
docs/changelog/134887.yaml

@@ -0,0 +1,5 @@
+pr: 134887
+summary: Avoid holding references to `SearchExecutionContext` in `SourceConfirmedTextQuery`
+area: Mapping
+type: bug
+issues: []

+ 2 - 2
modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapper.java

@@ -301,9 +301,9 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
                 String name = storedFieldNameForSyntheticSource();
                 return storedFieldFetcher(name);
             }
+            ValueFetcher valueFetcher = valueFetcher(searchExecutionContext, null);
+            SourceProvider sourceProvider = searchExecutionContext.lookup();
             return context -> {
-                ValueFetcher valueFetcher = valueFetcher(searchExecutionContext, null);
-                SourceProvider sourceProvider = searchExecutionContext.lookup();
                 valueFetcher.setNextReader(context);
                 return docID -> {
                     try {