Skip to content

Commit 40c593c

Browse files
committed
Fix potential block leak in LuceneSourceOperator
1 parent 850d48a commit 40c593c

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

muted-tests.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -341,24 +341,10 @@ tests:
341341
- class: org.elasticsearch.xpack.searchablesnapshots.FrozenSearchableSnapshotsIntegTests
342342
method: testCreateAndRestorePartialSearchableSnapshot
343343
issue: https://github.com/elastic/elasticsearch/issues/123773
344-
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
345-
method: testDropAllColumns
346-
issue: https://github.com/elastic/elasticsearch/issues/123791
344+
347345
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
348346
method: test {p0=snapshot/10_basic/Create a source only snapshot and then restore it}
349347
issue: https://github.com/elastic/elasticsearch/issues/122755
350-
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
351-
method: testFromStatsGroupingByDate
352-
issue: https://github.com/elastic/elasticsearch/issues/123808
353-
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
354-
method: testDefaultTruncationSizeSetting
355-
issue: https://github.com/elastic/elasticsearch/issues/123809
356-
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
357-
method: testFromStatsEvalWithPragma
358-
issue: https://github.com/elastic/elasticsearch/issues/123810
359-
- class: org.elasticsearch.xpack.esql.action.EsqlActionBreakerIT
360-
method: testProjectRenameEval
361-
issue: https://github.com/elastic/elasticsearch/issues/123811
362348

363349
# Examples:
364350
#

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/LuceneSourceOperator.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,13 @@ private IntVector buildDocsVector(int upToPositions) {
232232
if (docs.getPositionCount() == upToPositions) {
233233
return docs;
234234
}
235-
try (var slice = blockFactory.newIntVectorFixedBuilder(upToPositions)) {
236-
for (int i = 0; i < upToPositions; i++) {
237-
slice.appendInt(docs.getInt(i));
235+
try (docs) {
236+
try (var slice = blockFactory.newIntVectorFixedBuilder(upToPositions)) {
237+
for (int i = 0; i < upToPositions; i++) {
238+
slice.appendInt(docs.getInt(i));
239+
}
240+
return slice.build();
238241
}
239-
docs.close();
240-
return slice.build();
241242
}
242243
}
243244

@@ -247,12 +248,13 @@ private DoubleVector buildScoresVector(int upToPositions) {
247248
if (scores.getPositionCount() == upToPositions) {
248249
return scores;
249250
}
250-
try (var slice = blockFactory.newDoubleVectorBuilder(upToPositions)) {
251-
for (int i = 0; i < upToPositions; i++) {
252-
slice.appendDouble(scores.getDouble(i));
251+
try (scores) {
252+
try (var slice = blockFactory.newDoubleVectorBuilder(upToPositions)) {
253+
for (int i = 0; i < upToPositions; i++) {
254+
slice.appendDouble(scores.getDouble(i));
255+
}
256+
return slice.build();
253257
}
254-
scores.close();
255-
return slice.build();
256258
}
257259
}
258260

0 commit comments

Comments
 (0)