From 842efe55d33f73f9d82fd21327140bfa4edc74c4 Mon Sep 17 00:00:00 2001 From: Ulrich Kramer Date: Wed, 7 Feb 2024 14:10:26 +0100 Subject: [PATCH] [CALCITE-6251] InnerEnumerator in EnumerableDefaults::correlateBatchJoin is not closed --- .../org/apache/calcite/linq4j/EnumerableDefaults.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java b/linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java index 3d2c1415745..e2338220bbc 100644 --- a/linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java +++ b/linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java @@ -1717,6 +1717,7 @@ public static Enumerable correlateBatchJoin( if (innerEnumerable == null) { innerEnumerable = Linq4j.emptyEnumerable(); } + closeInner(); innerEnumerator = innerEnumerable.enumerator(); innerEnumHasNext = innerEnumerator.moveNext(); @@ -1799,11 +1800,16 @@ private boolean innerHasNext() { i = -1; } - @Override public void close() { - outerEnumerator.close(); + private void closeInner() { if (innerEnumerator != null) { innerEnumerator.close(); + innerEnumerator = null; } + } + + @Override public void close() { + outerEnumerator.close(); + closeInner(); outerValue = null; innerValue = null; }