Class SpelParserConfiguration
Rather than using one of the numerous constructors in this class, it is
strongly recommended that you use the builder API to
configure and create a SpelParserConfiguration instance, since the
builder only requires configuration of the properties that need to deviate from
their sensible defaults — or use withDefaults() if none of those
defaults need to be overridden. Note that the constructors in this class have
been deprecated in favor of the builder as of Spring Framework 7.1.
- Since:
- 3.0
- Author:
- Juergen Hoeller, Phillip Webb, Andy Clement, Sam Brannen
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder API forSpelParserConfiguration. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum size to which a collection or array can automatically grow: 256.static final intDefault maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation within a SpEL expression: 1000000.static final intDefault maximum length permitted for a SpEL expression: 10000.static final intDefault maximum nesting depth permitted within a SpEL expression: 1000.static final intDefault maximum number of operations permitted during SpEL expression evaluation: 10000.static final StringSystem property to configure the default compiler mode for SpEL expression parsers: "spring.expression.compiler.mode".static final StringSystem property to configure the default maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation within a SpEL expression: "spring.expression.maxBigPowerBits".static final StringSystem property to configure the default maximum number of operations permitted during SpEL expression evaluation: "spring.expression.maxOperations". -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.SpelParserConfiguration(boolean autoGrowNullReferences, boolean autoGrowCollections) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength, int maximumOperations) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength, int maximumOperations, int maximumBigPowerBits) Deprecated.as of Spring Framework 7.1, in favor of the builder APISpelParserConfiguration(SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength, int maximumOperations, int maximumBigPowerBits, int maximumNestingDepth) Deprecated.as of Spring Framework 7.1, in favor of the builder API -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Create a newSpelParserConfiguration.Builderfor configuring aSpelParserConfiguration.Return theClassLoaderto use as the basis for expression compilation.Return the compiler mode for parsers using this configuration object.intReturn the maximum size to which a collection can auto grow.intReturn the maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation.intReturn the maximum number of characters that a SpEL expression can contain.intReturn the maximum nesting depth permitted within a SpEL expression.intReturn the maximum number of operations permitted during SpEL expression evaluation.booleanReturntrueif collections should be automatically grown.booleanReturntrueifnullreferences should be automatically grown.static SpelParserConfigurationCreate a newSpelParserConfigurationinstance with the same defaults applied bybuilder().
-
Field Details
-
DEFAULT_MAX_AUTO_GROW_SIZE
public static final int DEFAULT_MAX_AUTO_GROW_SIZEDefault maximum size to which a collection or array can automatically grow: 256.Aligned with the default auto-grow limit used for Spring's data binding support (see
DataBinder.DEFAULT_AUTO_GROW_COLLECTION_LIMIT), for consistency between SpEL and data binding.- Since:
- 7.1
- See Also:
-
DEFAULT_MAX_EXPRESSION_LENGTH
public static final int DEFAULT_MAX_EXPRESSION_LENGTHDefault maximum length permitted for a SpEL expression: 10000.- Since:
- 5.2.24
- See Also:
-
DEFAULT_MAX_OPERATIONS
public static final int DEFAULT_MAX_OPERATIONSDefault maximum number of operations permitted during SpEL expression evaluation: 10000.- Since:
- 6.2.19
- See Also:
-
DEFAULT_MAX_BIG_POWER_BITS
public static final int DEFAULT_MAX_BIG_POWER_BITSDefault maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation within a SpEL expression: 1000000.Approximately equivalent to a decimal number with 300,000 digits.
- Since:
- 7.0.9
- See Also:
-
DEFAULT_MAX_EXPRESSION_NESTING_DEPTH
public static final int DEFAULT_MAX_EXPRESSION_NESTING_DEPTHDefault maximum nesting depth permitted within a SpEL expression: 1000.This limit guards against deeply nested constructs (for example, nested inline lists or maps, parenthesized expressions, ternary or Elvis expressions, or chained unary operators) that could otherwise drive SpEL's recursive-descent parser to exhaust the current thread's call stack.
NOTE: This limit improves diagnostics for the common case by converting what would otherwise be an opaque
StackOverflowErrorinto a descriptiveSpelParseException, but it is not a guaranteed defense againstStackOverflowErrorunder every possible JVM thread stack size configuration. The amount of stack space consumed per level of nesting depends on the JVM, its current JIT compilation state, and the platform; consequently, this default may not suffice on threads configured with a substantially reduced stack size (for example, via a reduced-Xsssetting, as is sometimes done in high-concurrency deployments to support large thread pools). Applications and frameworks that evaluate SpEL expressions from an untrusted source should not rely on this limit alone; see the Security Considerations section of the Spring Framework reference documentation for further guidance on evaluating untrusted SpEL expressions.- Since:
- 7.1
- See Also:
-
SPRING_EXPRESSION_COMPILER_MODE_PROPERTY_NAME
System property to configure the default compiler mode for SpEL expression parsers: "spring.expression.compiler.mode".NOTE: Instead of relying on a global default, applications and frameworks should ideally set an explicit custom value via
SpelParserConfiguration.Builder.compilerMode(SpelCompilerMode), which provides complete configuration control and the ability to override global defaults per use case.Can also be configured via the
SpringPropertiesmechanism.- See Also:
-
SPRING_EXPRESSION_MAX_OPERATIONS_PROPERTY_NAME
System property to configure the default maximum number of operations permitted during SpEL expression evaluation: "spring.expression.maxOperations".NOTE: Instead of relying on a global default, applications and frameworks should ideally set an explicit custom value via
SpelParserConfiguration.Builder.maximumOperations(int), which provides complete configuration control and the ability to override global defaults per use case.Can also be configured via the
SpringPropertiesmechanism.- Since:
- 6.2.19
- See Also:
-
SPRING_EXPRESSION_MAX_BIG_POWER_BITS_PROPERTY_NAME
System property to configure the default maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation within a SpEL expression: "spring.expression.maxBigPowerBits".NOTE: Instead of relying on a global default, applications and frameworks should ideally set an explicit custom value via
SpelParserConfiguration.Builder.maximumBigPowerBits(int), which provides complete configuration control and the ability to override global defaults per use case.Can also be configured via the
SpringPropertiesmechanism.- Since:
- 7.0.9
- See Also:
-
-
Constructor Details
-
SpelParserConfiguration
Deprecated.as of Spring Framework 7.1, in favor ofwithDefaults()Create a newSpelParserConfigurationinstance with default settings.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
compilerMode- the compiler mode that parsers using this configuration should use; ornullto use the default modecompilerClassLoader- theClassLoaderto use as the basis for expression compilation; ornullto use the defaultClassLoader- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(boolean autoGrowNullReferences, boolean autoGrowCollections) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
autoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically grow- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
autoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically growmaximumAutoGrowSize- the maximum size to which a collection can auto grow; must not be negative, and a value of0effectively disables growing a collection beyond its current size- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
compilerMode- the compiler mode that parsers using this configuration should use; ornullto use the default modecompilerClassLoader- theClassLoaderto use as the basis for expression compilation; ornullto use the defaultClassLoaderautoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically growmaximumAutoGrowSize- the maximum size to which a collection can auto grow; must not be negative, and a value of0effectively disables growing a collection beyond its current size- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
compilerMode- the compiler mode that parsers using this configuration should use; ornullto use the default modecompilerClassLoader- theClassLoaderto use as the basis for expression compilation; ornullto use the defaultClassLoaderautoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically growmaximumAutoGrowSize- the maximum size to which a collection can auto grow; must not be negative, and a value of0effectively disables growing a collection beyond its current sizemaximumExpressionLength- the maximum length of a SpEL expression; must be a positive number- Since:
- 5.2.25
- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength, int maximumOperations) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
compilerMode- the compiler mode that parsers using this configuration should use; must not benullcompilerClassLoader- theClassLoaderto use as the basis for expression compilation; ornullto use the defaultClassLoaderautoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically growmaximumAutoGrowSize- the maximum size to which a collection can auto grow; must not be negative, and a value of0effectively disables growing a collection beyond its current sizemaximumExpressionLength- the maximum length of a SpEL expression; must be a positive numbermaximumOperations- the maximum number of operations permitted during SpEL expression evaluation; must be a positive number- Since:
- 6.2.19
- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength, int maximumOperations, int maximumBigPowerBits) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
compilerMode- the compiler mode that parsers using this configuration should use; must not benullcompilerClassLoader- theClassLoaderto use as the basis for expression compilation; ornullto use the defaultClassLoaderautoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically growmaximumAutoGrowSize- the maximum size to which a collection can auto grow; must not be negative, and a value of0effectively disables growing a collection beyond its current sizemaximumExpressionLength- the maximum length of a SpEL expression; must be a positive numbermaximumOperations- the maximum number of operations permitted during SpEL expression evaluation; must be a positive numbermaximumBigPowerBits- the maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation; must be a positive number; useInteger.MAX_VALUEfor no limit- Since:
- 7.0.9
- See Also:
-
SpelParserConfiguration
@Deprecated(since="7.1") public SpelParserConfiguration(SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength, int maximumOperations, int maximumBigPowerBits, int maximumNestingDepth) Deprecated.as of Spring Framework 7.1, in favor of the builder APICreate a newSpelParserConfigurationinstance.NOTE: Favor
builder()for complete configuration control and the ability to override global defaults per use case.- Parameters:
compilerMode- the compiler mode that parsers using this configuration should use; must not benullcompilerClassLoader- theClassLoaderto use as the basis for expression compilation; ornullto use the defaultClassLoaderautoGrowNullReferences- if null references should automatically growautoGrowCollections- if collections should automatically growmaximumAutoGrowSize- the maximum size to which a collection can auto grow; must not be negative, and a value of0effectively disables growing a collection beyond its current sizemaximumExpressionLength- the maximum length of a SpEL expression; must be a positive numbermaximumOperations- the maximum number of operations permitted during SpEL expression evaluation; must be a positive numbermaximumBigPowerBits- the maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation; must be a positive number; useInteger.MAX_VALUEfor no limitmaximumNestingDepth- the maximum nesting depth permitted within a SpEL expression; must be a positive number- Since:
- 7.1
-
-
Method Details
-
withDefaults
Create a newSpelParserConfigurationinstance with the same defaults applied bybuilder().This is shorthand for
SpelParserConfiguration.builder().build(), for use whenever none of the defaults need to be overridden.- Since:
- 7.0.10
- See Also:
-
builder
Create a newSpelParserConfiguration.Builderfor configuring aSpelParserConfiguration.The builder only requires configuration of the properties that need to deviate from their sensible defaults. See
SpelParserConfiguration.Builderfor details on those defaults.- Since:
- 7.0.10
- See Also:
-
getCompilerMode
Return the compiler mode for parsers using this configuration object. -
getCompilerClassLoader
Return theClassLoaderto use as the basis for expression compilation. -
isAutoGrowNullReferences
public boolean isAutoGrowNullReferences()Returntrueifnullreferences should be automatically grown. -
isAutoGrowCollections
public boolean isAutoGrowCollections()Returntrueif collections should be automatically grown. -
getMaximumAutoGrowSize
public int getMaximumAutoGrowSize()Return the maximum size to which a collection can auto grow.- See Also:
-
getMaximumExpressionLength
public int getMaximumExpressionLength()Return the maximum number of characters that a SpEL expression can contain.- Since:
- 5.2.25
-
getMaximumOperations
public int getMaximumOperations()Return the maximum number of operations permitted during SpEL expression evaluation.- Since:
- 6.2.19
-
getMaximumBigPowerBits
public int getMaximumBigPowerBits()Return the maximum number of bits permitted in the result of aBigDecimalorBigIntegerpower operation.- Since:
- 7.0.9
-
getMaximumNestingDepth
public int getMaximumNestingDepth()Return the maximum nesting depth permitted within a SpEL expression.- Since:
- 7.1
- See Also:
-
withDefaults()