Skip to content

Commit 60de4a5

Browse files
committed
[SPARK-42071][CORE] Register scala.math.Ordering$Reverse to KyroSerializer
This PR aims to register `scala.math.Ordering$Reverse` to KyroSerializer. Scala 2.12.12 added a new class 'Reverse' via scala/scala#8965. This affects Apache Spark 3.2.0+. No. Pass the CIs with newly added test case. Closes apache#39578 from dongjoon-hyun/SPARK-42071. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit e3c0fbe) Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 4e8907a commit 60de4a5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ class KryoSerializer(conf: SparkConf)
219219
kryo.register(Nil.getClass)
220220
kryo.register(Utils.classForName("scala.collection.immutable.$colon$colon"))
221221
kryo.register(Utils.classForName("scala.collection.immutable.Map$EmptyMap$"))
222+
kryo.register(Utils.classForName("scala.math.Ordering$Reverse"))
222223
kryo.register(classOf[ArrayBuffer[Any]])
223224

224225
// We can't load those class directly in order to avoid unnecessary jar dependencies.

core/src/test/scala/org/apache/spark/serializer/KryoSerializerSuite.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import org.apache.spark.internal.io.FileCommitProtocol.TaskCommitMessage
3838
import org.apache.spark.scheduler.HighlyCompressedMapStatus
3939
import org.apache.spark.serializer.KryoTest._
4040
import org.apache.spark.storage.BlockManagerId
41-
import org.apache.spark.util.ThreadUtils
41+
import org.apache.spark.util.{ThreadUtils, Utils}
4242

4343
class KryoSerializerSuite extends SparkFunSuite with SharedSparkContext {
4444
conf.set(SERIALIZER, "org.apache.spark.serializer.KryoSerializer")
@@ -171,6 +171,18 @@ class KryoSerializerSuite extends SparkFunSuite with SharedSparkContext {
171171
mutable.HashMap(1 -> "one", 2 -> "two", 3 -> "three")))
172172
}
173173

174+
test("SPARK-42071: Register scala.math.Ordering$Reverse") {
175+
val conf = new SparkConf(false)
176+
conf.set(KRYO_REGISTRATION_REQUIRED, true)
177+
178+
val ser = new KryoSerializer(conf).newInstance()
179+
def check[T: ClassTag](t: T): Unit = {
180+
assert(ser.deserialize[T](ser.serialize(t)) === t)
181+
}
182+
// Scala 2.12.12 added a new class 'Reverse' via https://github.com/scala/scala/pull/8965
183+
check(Utils.classForName("scala.math.Ordering$Reverse"))
184+
}
185+
174186
test("Bug: SPARK-10251") {
175187
val ser = new KryoSerializer(conf.clone.set(KRYO_REGISTRATION_REQUIRED, true))
176188
.newInstance()

0 commit comments

Comments
 (0)