Package org.apache.avro
Class SystemLimitException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.avro.AvroRuntimeException
org.apache.avro.SystemLimitException
- All Implemented Interfaces:
Serializable
Thrown to prevent making large allocations when reading potentially
pathological input data from an untrusted source.
The following system properties can be set to limit the size of bytes,
strings and collection types to be allocated:
- org.apache.avro.limits.byte.maxLength limits the maximum size of byte types.
- org.apache.avro.limits.collectionItems.maxLength limits the maximum number of map and list items that can be read at once single sequence.
- org.apache.avro.limits.string.maxLength limits the maximum size of string types.
MAX_ARRAY_VM_LIMIT
.- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
checkMaxBytesLength
(long length) Check to ensure that reading the bytes is within the specified limits.static int
checkMaxCollectionLength
(long items) Check to ensure that reading the specified number of items remains within the specified limits.static int
checkMaxCollectionLength
(long existing, long items) Check to ensure that reading the specified number of items remains within the specified limits.static int
checkMaxStringLength
(long length) Check to ensure that reading the string size is within the specified limits.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
MAX_BYTES_LENGTH_PROPERTY
- See Also:
-
MAX_COLLECTION_LENGTH_PROPERTY
- See Also:
-
MAX_STRING_LENGTH_PROPERTY
- See Also:
-
-
Constructor Details
-
SystemLimitException
-
-
Method Details
-
checkMaxBytesLength
public static int checkMaxBytesLength(long length) Check to ensure that reading the bytes is within the specified limits.- Parameters:
length
- The proposed size of the bytes to read- Returns:
- The size of the bytes if and only if it is within the limit and non-negative.
- Throws:
UnsupportedOperationException
- if reading the datum would allocate a collection that the Java VM would be unable to handleSystemLimitException
- if the decoding should fail because it would otherwise result in an allocation exceeding the set limitAvroRuntimeException
- if the length is negative
-
checkMaxCollectionLength
public static int checkMaxCollectionLength(long existing, long items) Check to ensure that reading the specified number of items remains within the specified limits.- Parameters:
existing
- The number of elements items read in the collectionitems
- The next number of items to read. In normal usage, this is always a positive, permitted value. Negative and zero values have a special meaning in Avro decoding.- Returns:
- The total number of items in the collection if and only if it is within the limit and non-negative.
- Throws:
UnsupportedOperationException
- if reading the items would allocate a collection that the Java VM would be unable to handleSystemLimitException
- if the decoding should fail because it would otherwise result in an allocation exceeding the set limitAvroRuntimeException
- if the length is negative
-
checkMaxCollectionLength
public static int checkMaxCollectionLength(long items) Check to ensure that reading the specified number of items remains within the specified limits.- Parameters:
items
- The next number of items to read. In normal usage, this is always a positive, permitted value. Negative and zero values have a special meaning in Avro decoding.- Returns:
- The total number of items in the collection if and only if it is within the limit and non-negative.
- Throws:
UnsupportedOperationException
- if reading the items would allocate a collection that the Java VM would be unable to handleSystemLimitException
- if the decoding should fail because it would otherwise result in an allocation exceeding the set limitAvroRuntimeException
- if the length is negative
-
checkMaxStringLength
public static int checkMaxStringLength(long length) Check to ensure that reading the string size is within the specified limits.- Parameters:
length
- The proposed size of the string to read- Returns:
- The size of the string if and only if it is within the limit and non-negative.
- Throws:
UnsupportedOperationException
- if reading the items would allocate a collection that the Java VM would be unable to handleSystemLimitException
- if the decoding should fail because it would otherwise result in an allocation exceeding the set limitAvroRuntimeException
- if the length is negative
-