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

Set large StreamReadConstraints.maxStringLength for IR parsing only #354

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 0 additions & 13 deletions hail/src/main/scala/is/hail/backend/Backend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import scala.reflect.ClassTag
import java.io._
import java.nio.charset.StandardCharsets

import com.fasterxml.jackson.core.StreamReadConstraints
import org.json4s._
import org.json4s.jackson.{JsonMethods, Serialization}

Expand Down Expand Up @@ -55,18 +54,6 @@ trait BackendContext {
}

abstract class Backend {
// From https://github.com/hail-is/hail/issues/14580 :
// IR can get quite big, especially as it can contain an arbitrary
// amount of encoded literals from the user's python session. This
// was a (controversial) restriction imposed by Jackson and should be lifted.
//
// We remove this restriction for all backends, and we do so here, in the
// constructor since constructing a backend is one of the first things that
// happens and this constraint should be overrided as early as possible.
StreamReadConstraints.overrideDefaultStreamReadConstraints(
StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build()
)

val persistedIR: mutable.Map[Int, BaseIR] = mutable.Map()

protected[this] def addJavaIR(ir: BaseIR): Int = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ 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._
Expand Down Expand Up @@ -464,7 +465,12 @@ object ServiceBackendAPI {

implicit val formats: Formats = DefaultFormats

StreamReadConstraints.overrideDefaultStreamReadConstraints(
StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build()
)
val input = using(fs.openNoCompression(inputURL))(JsonMethods.parse(_))
StreamReadConstraints.overrideDefaultStreamReadConstraints(StreamReadConstraints.builder().build())

val rpcConfig = (input \ "config").extract[ServiceBackendRPCPayload]

// FIXME: when can the classloader be shared? (optimizer benefits!)
Expand Down