Skip to content

Commit b62ebd9

Browse files
szhemsrowen
authored andcommitted
[SPARK-20404][CORE] Using Option(name) instead of Some(name)
Using Option(name) instead of Some(name) to prevent runtime failures when using accumulators created like the following ``` sparkContext.accumulator(0, null) ``` Author: Sergey Zhemzhitsky <szhemzhitski@gmail.com> Closes #17740 from szhem/SPARK-20404-null-acc-names. (cherry picked from commit 0bc7a90) Signed-off-by: Sean Owen <sowen@cloudera.com>
1 parent c18de9c commit b62ebd9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ class SparkContext(config: SparkConf) extends Logging {
13501350
@deprecated("use AccumulatorV2", "2.0.0")
13511351
def accumulator[T](initialValue: T, name: String)(implicit param: AccumulatorParam[T])
13521352
: Accumulator[T] = {
1353-
val acc = new Accumulator(initialValue, param, Some(name))
1353+
val acc = new Accumulator(initialValue, param, Option(name))
13541354
cleaner.foreach(_.registerAccumulatorForCleanup(acc.newAcc))
13551355
acc
13561356
}
@@ -1379,7 +1379,7 @@ class SparkContext(config: SparkConf) extends Logging {
13791379
@deprecated("use AccumulatorV2", "2.0.0")
13801380
def accumulable[R, T](initialValue: R, name: String)(implicit param: AccumulableParam[R, T])
13811381
: Accumulable[R, T] = {
1382-
val acc = new Accumulable(initialValue, param, Some(name))
1382+
val acc = new Accumulable(initialValue, param, Option(name))
13831383
cleaner.foreach(_.registerAccumulatorForCleanup(acc.newAcc))
13841384
acc
13851385
}
@@ -1414,7 +1414,7 @@ class SparkContext(config: SparkConf) extends Logging {
14141414
* @note Accumulators must be registered before use, or it will throw exception.
14151415
*/
14161416
def register(acc: AccumulatorV2[_, _], name: String): Unit = {
1417-
acc.register(this, name = Some(name))
1417+
acc.register(this, name = Option(name))
14181418
}
14191419

14201420
/**

0 commit comments

Comments
 (0)