ReaderConfig

class ReaderConfig extends Serializable

Configuration for com.github.plokhotnyuk.jsoniter_scala.core.JsonReader that contains flags for tuning of parsing exceptions and preferred sizes for internal buffers that are created on the reader instantiation and reused in runtime for parsing of messages.
All configuration params already initialized by recommended default values, but in some cases they should be altered for performance reasons:

  • turn off stack traces for parsing exceptions to greatly reduce impact on performance for cases when exceptions can be not exceptional (e.g. under DoS attacks over open to the world systems), see more details here: https://shipilev.net/blog/2014/exceptional-performance/

  • turn off appending of hex dump to minimize length of exception message

  • increase preferred size of an internal byte buffer for parsing from java.io.InputStream or java.nio.DirectByteBuffer to reduce allocation rate of grown and then reduced buffers during parsing of large (>16Kb) numbers (including stringified), raw values, or ADT instances with the discriminator field doesn't appear in the beginning of the JSON object

  • increase preferred size of an internal char buffer to reduce allocation rate of grown and then reduced buffers when large (>4Kb) string instances need to be parsed including those one which use Base16 or Base64 encodings

Value parameters:
appendHexDumpToParseException

a flag that allows to turn off hex dumping of affected by error part of an internal byte buffer

checkForEndOfInput

a flag to check and raise an error if some non whitespace bytes will be detected after successful parsing of the value

hexDumpSize

a size of the hex dump in 16-byte lines before and after the 16-byte line where an error occurs

preferredBufSize

a preferred size (in bytes) of an internal byte buffer when parsing from java.io.InputStream

preferredCharBufSize

a preferred size (in chars) of an internal char buffer for parsing of string values

throwReaderExceptionWithStackTrace

a flag that allows to turn on a stack traces for debugging purposes in development

Companion:
object
trait Serializable
class Object
trait Matchable
class Any
object ReaderConfig.type

Value members

Concrete methods

def withAppendHexDumpToParseException(appendHexDumpToParseException: Boolean): ReaderConfig
def withCheckForEndOfInput(checkForEndOfInput: Boolean): ReaderConfig
def withHexDumpSize(hexDumpSize: Int): ReaderConfig
def withPreferredBufSize(preferredBufSize: Int): ReaderConfig
def withPreferredCharBufSize(preferredCharBufSize: Int): ReaderConfig
def withThrowReaderExceptionWithStackTrace(throwReaderExceptionWithStackTrace: Boolean): ReaderConfig