File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
main/scala/org/apache/spark/util
test/scala/org/apache/spark/util Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -920,14 +920,10 @@ private[spark] class JsonProtocol(sparkConf: SparkConf) extends JsonUtils {
920
920
case `blockUpdate` => blockUpdateFromJson(json)
921
921
case `resourceProfileAdded` => resourceProfileAddedFromJson(json)
922
922
case other =>
923
- if (other.startsWith(" org.apache.spark" )) {
924
- val otherClass = Utils .classForName(other)
925
- if (classOf [SparkListenerEvent ].isAssignableFrom(otherClass)) {
926
- mapper.readValue(json.toString, otherClass)
927
- .asInstanceOf [SparkListenerEvent ]
928
- } else {
929
- throw new SparkException (s " Unknown event type: $other" )
930
- }
923
+ val otherClass = Utils .classForName(other)
924
+ if (classOf [SparkListenerEvent ].isAssignableFrom(otherClass)) {
925
+ mapper.readValue(json.toString, otherClass)
926
+ .asInstanceOf [SparkListenerEvent ]
931
927
} else {
932
928
throw new SparkException (s " Unknown event type: $other" )
933
929
}
Original file line number Diff line number Diff line change @@ -1023,18 +1023,17 @@ class jsonProtocolSuite extends SparkFunSuite {
1023
1023
))
1024
1024
}
1025
1025
1026
- test(" SPARK-52381: only read Spark classes " ) {
1026
+ test(" SPARK-52381: handle class not found " ) {
1027
1027
val unknownJson =
1028
1028
""" {
1029
1029
| "Event" : "com.example.UnknownEvent",
1030
1030
| "foo" : "foo"
1031
1031
|}""" .stripMargin
1032
1032
try {
1033
1033
jsonProtocol.sparkEventFromJson(unknownJson)
1034
- fail(" Expected SparkException for unknown event type" )
1034
+ fail(" Expected ClassNotFoundException for unknown event type" )
1035
1035
} catch {
1036
- case e : SparkException =>
1037
- assert(e.getMessage.startsWith(" Unknown event type" ))
1036
+ case e : ClassNotFoundException =>
1038
1037
}
1039
1038
}
1040
1039
You can’t perform that action at this time.
0 commit comments