diff --git a/sql-plugin/src/main/scala/com/nvidia/spark/rapids/spill/SpillFramework.scala b/sql-plugin/src/main/scala/com/nvidia/spark/rapids/spill/SpillFramework.scala index 57f2a823432..91421a37c64 100644 --- a/sql-plugin/src/main/scala/com/nvidia/spark/rapids/spill/SpillFramework.scala +++ b/sql-plugin/src/main/scala/com/nvidia/spark/rapids/spill/SpillFramework.scala @@ -1719,7 +1719,7 @@ class ChunkedPacker(table: Table, } override def next(): (DeviceBounceBuffer, Long) = { - withResource(bounceBufferPool.nextBuffer()) { bounceBuffer => + closeOnExcept(bounceBufferPool.nextBuffer()) { bounceBuffer => if (closed) { throw new IllegalStateException(s"ChunkedPacker is closed") }