Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[query] fix jackson max string length in backend http handler #14638

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hail/src/main/scala/is/hail/backend/BackendServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class BackendHttpHandler(backend: Backend) extends HttpHandler {
implicit val formats: Formats = DefaultFormats

try {
val body = using(exchange.getRequestBody)(JsonMethods.parse(_))
val body = using(exchange.getRequestBody)(parseJSON(_))
if (exchange.getRequestURI.getPath == "/execute") {
val config = body.extract[ExecutePayload]
backend.execute(config.ir, config.timed) { (ctx, res, timings) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import java.io._
import java.nio.charset.StandardCharsets
import java.util.concurrent._

import com.fasterxml.jackson.core.StreamReadConstraints
import org.apache.log4j.Logger
import org.json4s.{DefaultFormats, Formats}
import org.json4s.JsonAST._
import org.json4s.jackson.JsonMethods

class ServiceBackendContext(
val billingProject: String,
Expand Down Expand Up @@ -465,10 +463,7 @@ object ServiceBackendAPI {

implicit val formats: Formats = DefaultFormats

StreamReadConstraints.overrideDefaultStreamReadConstraints(
StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build()
);
val input = using(fs.openNoCompression(inputURL))(JsonMethods.parse(_))
val input = using(fs.openNoCompression(inputURL))(parseJSON(_))
val rpcConfig = (input \ "config").extract[ServiceBackendRPCPayload]

// FIXME: when can the classloader be shared? (optimizer benefits!)
Expand Down
12 changes: 10 additions & 2 deletions hail/src/main/scala/is/hail/utils/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import java.util.concurrent.{
}
import java.util.concurrent.atomic.AtomicBoolean

import com.fasterxml.jackson.core.StreamReadConstraints
import com.google.common.util.concurrent.AbstractFuture
import org.apache.commons.io.output.TeeOutputStream
import org.apache.commons.lang3.StringUtils
Expand All @@ -35,9 +36,9 @@ import org.apache.hadoop.mapreduce.lib.input.{FileSplit => NewFileSplit}
import org.apache.log4j.Level
import org.apache.spark.{Partition, TaskContext}
import org.apache.spark.sql.Row
import org.json4s.{Extraction, Formats, JObject, NoTypeHints, Serializer}
import org.json4s.{Extraction, Formats, JObject, JValue, JsonInput, NoTypeHints, Serializer}
import org.json4s.JsonAST.{JArray, JString}
import org.json4s.jackson.Serialization
import org.json4s.jackson.{JsonMethods, Serialization}
import org.json4s.reflect.TypeInfo

package utils {
Expand Down Expand Up @@ -527,6 +528,13 @@ package object utils

val defaultJSONFormats: Formats = Serialization.formats(NoTypeHints) + GenericIndexedSeqSerializer

def parseJSON(in: JsonInput): JValue = {
StreamReadConstraints.overrideDefaultStreamReadConstraints(
StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build()
)
JsonMethods.parse(in)
}

def box(i: Int): java.lang.Integer = i

def box(l: Long): java.lang.Long = l
Expand Down