You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ya...@apache.org on 2025/05/25 13:09:47 UTC
(spark) branch master updated: [SPARK-52299][CORE] replace deprecated JsonNode.fields
This is an automated email from the ASF dual-hosted git repository.
yangjie01 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 486d99ae6a95 [SPARK-52299][CORE] replace deprecated JsonNode.fields
486d99ae6a95 is described below
commit 486d99ae6a952b0daaadaab45a09e46214c9b92e
Author: xingyue <xi...@baidu.com>
AuthorDate: Sun May 25 21:09:33 2025 +0800
[SPARK-52299][CORE] replace deprecated JsonNode.fields
### What changes were proposed in this pull request?
JsonNode.fields is deprecated, and is supposed to be replaced as JsonNode.properties.
### Why are the changes needed?
Without the fix, there're warning during compile:
[warn] /path/to/spark/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala:1026:10: method fields in class JsonNode is deprecated
[warn] Applicable -Wconf / nowarn filters for this warning: msg=<part of the message>, cat=deprecation, site=org.apache.spark.util.JsonProtocol.taskResourceRequestMapFromJson, origin=com.fasterxml.jackson.databind.JsonNode.fields
[warn] json.fields().asScala.collect { case field =>
[warn] ^
### Does this PR introduce _any_ user-facing change?
No, it only fixes compilation warning.
### How was this patch tested?
after the fix, no such warning during compilation. all ut passes.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #51011 from yuexing/SPARK-52299.
Authored-by: xingyue <xi...@baidu.com>
Signed-off-by: yangjie01 <ya...@baidu.com>
---
core/src/main/scala/org/apache/spark/util/JsonProtocol.scala | 8 ++++----
core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala b/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala
index 0a01ca4b93d2..d4b9b3c2ef3a 100644
--- a/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala
+++ b/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala
@@ -1023,14 +1023,14 @@ private[spark] class JsonProtocol(sparkConf: SparkConf) extends JsonUtils {
}
def taskResourceRequestMapFromJson(json: JsonNode): Map[String, TaskResourceRequest] = {
- json.fields().asScala.collect { case field =>
+ json.properties().asScala.collect { case field =>
val req = taskResourceRequestFromJson(field.getValue)
(field.getKey, req)
}.toMap
}
def executorResourceRequestMapFromJson(json: JsonNode): Map[String, ExecutorResourceRequest] = {
- json.fields().asScala.collect { case field =>
+ json.properties().asScala.collect { case field =>
val req = executorResourceRequestFromJson(field.getValue)
(field.getKey, req)
}.toMap
@@ -1543,7 +1543,7 @@ private[spark] class JsonProtocol(sparkConf: SparkConf) extends JsonUtils {
def resourcesMapFromJson(json: JsonNode): Map[String, ResourceInformation] = {
assert(json.isObject, s"expected object, got ${json.getNodeType}")
- json.fields.asScala.map { field =>
+ json.properties.asScala.map { field =>
val resourceInfo = ResourceInformation.parseJson(field.getValue.toString)
(field.getKey, resourceInfo)
}.toMap
@@ -1555,7 +1555,7 @@ private[spark] class JsonProtocol(sparkConf: SparkConf) extends JsonUtils {
def mapFromJson(json: JsonNode): Map[String, String] = {
assert(json.isObject, s"expected object, got ${json.getNodeType}")
- json.fields.asScala.map { field =>
+ json.properties.asScala.map { field =>
(field.getKey, field.getValue.extractString)
}.toMap
}
diff --git a/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala b/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
index 132bdc285a71..115d1f34bcb4 100644
--- a/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
@@ -1356,7 +1356,7 @@ private[spark] object jsonProtocolSuite extends Assertions {
case ((key1, values1: scala.collection.Seq[(String, String)]),
(key2, values2: scala.collection.Seq[(String, String)])) =>
assert(key1 === key2)
- values1.zip(values2).foreach { case (v1, v2) => assert(v1 === v2) }
+ assert(values1.toMap == values2.toMap)
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org