Class NestedDeserialization$


  • public class NestedDeserialization$
    extends java.lang.Object
    INTERNAL API

    Bounds how deeply one deserialization may nest.

    Several wire formats carry a nested payload: the enclosed message is an opaque byte array that is deserialized in turn, and that payload may itself enclose another. Each level is parsed on its own, so a protobuf parser's nesting limit does not bound the chain - only the size of the message does. Recursion therefore tracks the nesting rather than the size of the message, and a sufficiently deep chain fails with a StackOverflowError instead of a serialization error.

    The depth is per thread because one message is deserialized synchronously on one thread.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static NestedDeserialization$ MODULE$
      Static reference to the singleton instance of this Scala object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T atNextLevel​(int max, scala.Function0<T> body)
      Runs body one level deeper, failing with NotSerializableException - the ordinary way a message that cannot be deserialized is reported - when the nesting exceeds max.
      int currentDepth()
      Current nesting depth, for testing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULE$

        public static final NestedDeserialization$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • NestedDeserialization$

        public NestedDeserialization$()
    • Method Detail

      • atNextLevel

        public <T> T atNextLevel​(int max,
                                 scala.Function0<T> body)
        Runs body one level deeper, failing with NotSerializableException - the ordinary way a message that cannot be deserialized is reported - when the nesting exceeds max.
      • currentDepth

        public int currentDepth()
        Current nesting depth, for testing.