diff --git a/java/src/main/java/ai/rapids/cudf/ColumnVector.java b/java/src/main/java/ai/rapids/cudf/ColumnVector.java index d1c3777f2c4..61981b34615 100644 --- a/java/src/main/java/ai/rapids/cudf/ColumnVector.java +++ b/java/src/main/java/ai/rapids/cudf/ColumnVector.java @@ -907,24 +907,6 @@ private static native long stringConcatenationSepCol(long[] columnViews, // INTERNAL/NATIVE ACCESS ///////////////////////////////////////////////////////////////////////////// - /** - * Close all non-null buffers. Exceptions that occur during the process will - * be aggregated into a single exception thrown at the end. - */ - static void closeBuffers(AutoCloseable buffer) { - Throwable toThrow = null; - if (buffer != null) { - try { - buffer.close(); - } catch (Throwable t) { - toThrow = t; - } - } - if (toThrow != null) { - throw new RuntimeException(toThrow); - } - } - //////// // Native methods specific to cudf::column. These either take or create a cudf::column // instead of a cudf::column_view so they need to be used with caution. These should @@ -1114,13 +1096,17 @@ protected synchronized boolean cleanImpl(boolean logErrorIfNotClean) { if (!toClose.isEmpty()) { try { for (MemoryBuffer toCloseBuff : toClose) { - closeBuffers(toCloseBuff); - } - } catch (Throwable t) { - if (toThrow != null) { - toThrow.addSuppressed(t); - } else { - toThrow = t; + if (toCloseBuff != null) { + try { + toCloseBuff.close(); + } catch (Throwable t) { + if (toThrow != null) { + toThrow.addSuppressed(t); + } else { + toThrow = t; + } + } + } } } finally { toClose.clear(); diff --git a/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java b/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java index dd07df16553..763ecc763a5 100644 --- a/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java +++ b/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java @@ -594,9 +594,15 @@ protected synchronized boolean cleanImpl(boolean logErrorIfNotClean) { boolean neededCleanup = false; if (data != null || valid != null || offsets != null) { try { - ColumnVector.closeBuffers(data); - ColumnVector.closeBuffers(offsets); - ColumnVector.closeBuffers(valid); + if (data != null) { + data.close(); + } + if (offsets != null) { + offsets.close(); + } + if (valid != null) { + valid.close(); + } } finally { // Always mark the resource as freed even if an exception is thrown. // We cannot know how far it progressed before the exception, and