Skip to content

Commit 076618a

Browse files
committed
[SPARK-49872][CORE] Remove jackson JSON string length limitation
### What changes were proposed in this pull request? This is a surgical fix extracted from apache#49163 The default jackson string limit introduced in jackson 2.15 can be too small for certain workloads, and this PR removes this limitation to avoid any regression. ### Why are the changes needed? fix regression ### Does this PR introduce _any_ user-facing change? Yes, users won't hit this size limitation anymore. ### How was this patch tested? apache#49163 tested it. We won't add a test in this PR as generating a super large JSON will make the CI unstable. ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#52049 from cloud-fan/json. Lead-authored-by: Wenchen Fan <wenchen@databricks.com> Co-authored-by: Wenchen Fan <cloud0fan@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
1 parent 9f63d1d commit 076618a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/scala/org/apache/spark/util/JsonProtocol.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import java.util.{Properties, UUID}
2222
import scala.collection.Map
2323
import scala.jdk.CollectionConverters._
2424

25-
import com.fasterxml.jackson.core.JsonGenerator
25+
import com.fasterxml.jackson.core.{JsonGenerator, StreamReadConstraints}
2626
import com.fasterxml.jackson.databind.JsonNode
2727
import org.json4s.jackson.JsonMethods.compact
2828

@@ -66,6 +66,11 @@ private[spark] class JsonProtocolOptions(conf: SparkConf) {
6666
private[spark] object JsonProtocol extends JsonUtils {
6767
// TODO: Remove this file and put JSON serialization into each individual class.
6868

69+
// SPARK-49872: Remove jackson JSON string length limitation.
70+
mapper.getFactory.setStreamReadConstraints(
71+
StreamReadConstraints.builder().maxStringLength(Int.MaxValue).build()
72+
)
73+
6974
private[util]
7075
val defaultOptions: JsonProtocolOptions = new JsonProtocolOptions(new SparkConf(false))
7176

0 commit comments

Comments
 (0)