Skip to content

Commit d208f53

Browse files
authored
Fix leaking blocks in BlockUtils (#102716) (#102722)
1 parent e1ceecb commit d208f53

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

docs/changelog/102716.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 102716
2+
summary: Fix leaking blocks in `BlockUtils`
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/BlockUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,17 @@ public static Block[] fromList(BlockFactory blockFactory, List<List<Object>> lis
151151
wrappers[j].append.accept(values.get(j));
152152
}
153153
}
154-
return Arrays.stream(wrappers).map(b -> b.builder.build()).toArray(Block[]::new);
154+
final Block[] blocks = new Block[wrappers.length];
155+
try {
156+
for (int i = 0; i < blocks.length; i++) {
157+
blocks[i] = wrappers[i].builder.build();
158+
}
159+
return blocks;
160+
} finally {
161+
if (blocks[blocks.length - 1] == null) {
162+
Releasables.closeExpectNoException(blocks);
163+
}
164+
}
155165
} finally {
156166
Releasables.closeExpectNoException(wrappers);
157167
}

0 commit comments

Comments
 (0)