@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2017 the original author or authors .
* Copyright 2002 - 2023 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -25,11 +25,19 @@ import org.springframework.lang.Nullable;
@@ -25,11 +25,19 @@ import org.springframework.lang.Nullable;
* @author Juergen Hoeller
* @author Phillip Webb
* @author Andy Clement
* @author Sam Brannen
* @since 3 . 0
* @see org . springframework . expression . spel . standard . SpelExpressionParser # SpelExpressionParser ( SpelParserConfiguration )
* /
public class SpelParserConfiguration {
/ * *
* Default maximum length permitted for a SpEL expression .
* @since 5 . 2 . 24
* /
private static final int DEFAULT_MAX_EXPRESSION_LENGTH = 10_000 ;
private static final SpelCompilerMode defaultCompilerMode ;
static {
@ -50,6 +58,8 @@ public class SpelParserConfiguration {
@@ -50,6 +58,8 @@ public class SpelParserConfiguration {
private final int maximumAutoGrowSize ;
private final int maximumExpressionLength ;
/ * *
* Create a new { @code SpelParserConfiguration } instance with default settings .
@ -98,11 +108,30 @@ public class SpelParserConfiguration {
@@ -98,11 +108,30 @@ public class SpelParserConfiguration {
public SpelParserConfiguration ( @Nullable SpelCompilerMode compilerMode , @Nullable ClassLoader compilerClassLoader ,
boolean autoGrowNullReferences , boolean autoGrowCollections , int maximumAutoGrowSize ) {
this ( compilerMode , compilerClassLoader , autoGrowNullReferences , autoGrowCollections ,
maximumAutoGrowSize , DEFAULT_MAX_EXPRESSION_LENGTH ) ;
}
/ * *
* Create a new { @code SpelParserConfiguration } instance .
* @param compilerMode the compiler mode that parsers using this configuration object should use
* @param compilerClassLoader the ClassLoader to use as the basis for expression compilation
* @param autoGrowNullReferences if null references should automatically grow
* @param autoGrowCollections if collections should automatically grow
* @param maximumAutoGrowSize the maximum size that a collection can auto grow
* @param maximumExpressionLength the maximum length of a SpEL expression ;
* must be a positive number
* @since 5 . 2 . 25
* /
public SpelParserConfiguration ( @Nullable SpelCompilerMode compilerMode , @Nullable ClassLoader compilerClassLoader ,
boolean autoGrowNullReferences , boolean autoGrowCollections , int maximumAutoGrowSize , int maximumExpressionLength ) {
this . compilerMode = ( compilerMode ! = null ? compilerMode : defaultCompilerMode ) ;
this . compilerClassLoader = compilerClassLoader ;
this . autoGrowNullReferences = autoGrowNullReferences ;
this . autoGrowCollections = autoGrowCollections ;
this . maximumAutoGrowSize = maximumAutoGrowSize ;
this . maximumExpressionLength = maximumExpressionLength ;
}
@ -142,4 +171,12 @@ public class SpelParserConfiguration {
@@ -142,4 +171,12 @@ public class SpelParserConfiguration {
return this . maximumAutoGrowSize ;
}
/ * *
* Return the maximum number of characters that a SpEL expression can contain .
* @since 5 . 2 . 25
* /
public int getMaximumExpressionLength ( ) {
return this . maximumExpressionLength ;
}
}