You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2016/11/19 09:00:16 UTC
spark git commit: [SPARK-18448][CORE] SparkSession should implement
java.lang.AutoCloseable like JavaSparkContext
Repository: spark
Updated Branches:
refs/heads/master 2a40de408 -> db9fb9baa
[SPARK-18448][CORE] SparkSession should implement java.lang.AutoCloseable like JavaSparkContext
## What changes were proposed in this pull request?
Just adds `close()` + `Closeable` as a synonym for `stop()`. This makes it usable in Java in try-with-resources, as suggested by ash211 (`Closeable` extends `AutoCloseable` BTW)
## How was this patch tested?
Existing tests
Author: Sean Owen <so...@cloudera.com>
Closes #15932 from srowen/SPARK-18448.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/db9fb9ba
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/db9fb9ba
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/db9fb9ba
Branch: refs/heads/master
Commit: db9fb9baacbf8640dd37a507b7450db727c7e6ea
Parents: 2a40de4
Author: Sean Owen <so...@cloudera.com>
Authored: Sat Nov 19 09:00:11 2016 +0000
Committer: Sean Owen <so...@cloudera.com>
Committed: Sat Nov 19 09:00:11 2016 +0000
----------------------------------------------------------------------
.../main/scala/org/apache/spark/sql/SparkSession.scala | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/db9fb9ba/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala b/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
index 3045eb6..58b2ab3 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
@@ -18,6 +18,7 @@
package org.apache.spark.sql
import java.beans.Introspector
+import java.io.Closeable
import java.util.concurrent.atomic.AtomicReference
import scala.collection.JavaConverters._
@@ -72,7 +73,7 @@ import org.apache.spark.util.Utils
class SparkSession private(
@transient val sparkContext: SparkContext,
@transient private val existingSharedState: Option[SharedState])
- extends Serializable with Logging { self =>
+ extends Serializable with Closeable with Logging { self =>
private[sql] def this(sc: SparkContext) {
this(sc, None)
@@ -648,6 +649,13 @@ class SparkSession private(
}
/**
+ * Synonym for `stop()`.
+ *
+ * @since 2.2.0
+ */
+ override def close(): Unit = stop()
+
+ /**
* Parses the data type in our internal string representation. The data type string should
* have the same format as the one generated by `toString` in scala.
* It is only used by PySpark.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org