This is an automated email from the ASF dual-hosted git repository.
pan3793 pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 3654b9f21594 [SPARK-56532][CORE] Add `closeQuietly(AutoCloseable)`
overload to `SparkErrorUtils`
3654b9f21594 is described below
commit 3654b9f2159498e59508b9deeb5234a18d5d0ca4
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Fri Apr 17 22:31:49 2026 -0700
[SPARK-56532][CORE] Add `closeQuietly(AutoCloseable)` overload to
`SparkErrorUtils`
### What changes were proposed in this pull request?
This PR adds a new `closeQuietly(AutoCloseable)` overload to
`SparkErrorUtils`, alongside the existing `closeQuietly(Closeable)`.
**The existing API**
https://github.com/apache/spark/blob/0cdbb43624d07fc6ed10586bd20fcb52f39f1685/common/utils/src/main/scala/org/apache/spark/util/SparkErrorUtils.scala#L146
**New API**
```scala
def closeQuietly(closeable: AutoCloseable): Unit
```
### Why are the changes needed?
`Closeable` extends `AutoCloseable`, so the existing helper cannot accept
resources that implement `AutoCloseable` only. Common examples include JDBC
types (`Connection`, `Statement`, `ResultSet`), `java.util.stream.Stream`, and
RocksDB native handles (`Statistics`, `Options`, `ColumnFamilyOptions`, etc.).
Without this overload, call sites must duplicate the `try { x.close() } catch {
case _: Exception => }` pattern or cast to `Closeable`. Adding the overload
removes that boilerplate [...]
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.7
Closes #55400 from dongjoon-hyun/SPARK-56532.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.../main/scala/org/apache/spark/util/SparkErrorUtils.scala | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git
a/common/utils/src/main/scala/org/apache/spark/util/SparkErrorUtils.scala
b/common/utils/src/main/scala/org/apache/spark/util/SparkErrorUtils.scala
index 2f16c90ad714..5d4f812cf281 100644
--- a/common/utils/src/main/scala/org/apache/spark/util/SparkErrorUtils.scala
+++ b/common/utils/src/main/scala/org/apache/spark/util/SparkErrorUtils.scala
@@ -152,6 +152,17 @@ private[spark] trait SparkErrorUtils extends Logging {
}
}
}
+
+ /** Try to close by ignoring all exceptions. */
+ def closeQuietly(closeable: AutoCloseable): Unit = {
+ if (closeable != null) {
+ try {
+ closeable.close()
+ } catch {
+ case _: Exception =>
+ }
+ }
+ }
}
private[spark] object SparkErrorUtils extends SparkErrorUtils
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]