java.lang.Object
tools.jackson.core.StreamWriteConstraints
- All Implemented Interfaces:
Serializable
The constraints to use for streaming writes: used to guard against problematic
output by preventing processing of "too big" output constructs (values,
structures).
Constraints are registered with
TokenStreamFactory (such as
JsonFactory); if nothing explicitly specified, default
constraints are used.
Currently constrained aspects, with default settings, are:
- Maximum Nesting depth: default 500 (see
DEFAULT_MAX_DEPTH)
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intstatic final intDefault setting for maximum depth: seeStreamWriteConstraints.Builder.maxNestingDepth(int)for details. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String_constrainRef(String method) protected StreamConstraintsException_constructException(String msgTemplate, Object... args) builder()static StreamWriteConstraintsdefaults()intAccessor for maximum depth.static voidoverrideDefaultStreamWriteConstraints(StreamWriteConstraints streamWriteConstraints) Override the default StreamWriteConstraints.rebuild()voidvalidateNestingDepth(int depth) Convenience method that can be used to verify that the nesting depth does not exceed the maximum specified by this constraints object: if it does, aStreamConstraintsExceptionis thrown.
-
Field Details
-
DEFAULT_MAX_DEPTH
public static final int DEFAULT_MAX_DEPTHDefault setting for maximum depth: seeStreamWriteConstraints.Builder.maxNestingDepth(int)for details.Note: was
1000in Jackson 2.x; lowered in 3.0.- See Also:
-
_maxNestingDepth
protected final int _maxNestingDepth
-
-
Constructor Details
-
StreamWriteConstraints
protected StreamWriteConstraints(int maxNestingDepth)
-
-
Method Details
-
overrideDefaultStreamWriteConstraints
public static void overrideDefaultStreamWriteConstraints(StreamWriteConstraints streamWriteConstraints) Override the default StreamWriteConstraints. These defaults are only used whenTokenStreamFactoryinstances are not configured with their own StreamWriteConstraints.Library maintainers should not set this as it will affect other code that uses Jackson. Library maintainers who want to configure StreamWriteConstraints for the Jackson usage within their lib should create
ObjectMapperinstances that have aTokenStreamFactoryinstance with the required StreamWriteConstraints.This method is meant for users delivering applications. If they use this, they set it when they start their application to avoid having other code initialize their mappers before the defaults are overridden.
- Parameters:
streamWriteConstraints- new default for StreamWriteConstraints (a null value will reset to built-in default)- See Also:
-
builder
-
defaults
- Returns:
- the default
StreamWriteConstraints(when none is set on theTokenStreamFactoryexplicitly) - See Also:
-
rebuild
- Returns:
- New
StreamWriteConstraints.Builderinitialized with settings of this constraints instance
-
getMaxNestingDepth
public int getMaxNestingDepth()Accessor for maximum depth. seeStreamWriteConstraints.Builder.maxNestingDepth(int)for details.- Returns:
- Maximum allowed depth
-
validateNestingDepth
Convenience method that can be used to verify that the nesting depth does not exceed the maximum specified by this constraints object: if it does, aStreamConstraintsExceptionis thrown.- Parameters:
depth- count of unclosed objects and arrays- Throws:
StreamConstraintsException- If depth exceeds maximum
-
_constructException
protected StreamConstraintsException _constructException(String msgTemplate, Object... args) throws StreamConstraintsException - Throws:
StreamConstraintsException
-
_constrainRef
-