Skip to content

Commit 74b4489

Browse files
SPARK-5425: Use SerializationUtils to save properties in ResetSystemProperties trait
1 parent 685780e commit 74b4489

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/test/scala/org/apache/spark/util/ResetSystemProperties.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.apache.spark.util
1919

2020
import java.util.Properties
2121

22+
import org.apache.commons.lang3.SerializationUtils
2223
import org.scalatest.{BeforeAndAfterEach, Suite}
2324

2425
/**
@@ -42,7 +43,11 @@ private[spark] trait ResetSystemProperties extends BeforeAndAfterEach { this: Su
4243
var oldProperties: Properties = null
4344

4445
override def beforeEach(): Unit = {
45-
oldProperties = new Properties(System.getProperties)
46+
// we need SerializationUtils.clone instead of `new Properties(System.getProperties()` because
47+
// the later way of creating a copy does not copy the properties but it initializes a new
48+
// Properties object with the given properties as defaults. They are not recognized at all
49+
// by standard Scala wrapper over Java Properties then.
50+
oldProperties = SerializationUtils.clone(System.getProperties)
4651
super.beforeEach()
4752
}
4853

0 commit comments

Comments
 (0)