diff --git a/build.gradle b/build.gradle index 182be5ea1c3d..05a0177509d5 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,8 @@ buildscript { } } dependencies { + classpath("org.asciidoctor:asciidoctorj-groovy-dsl:1.0.0.preview2") + classpath("org.asciidoctor:asciidoctorj:1.5.2") classpath("io.spring.gradle:propdeps-plugin:0.0.10-TT.1") classpath("io.spring.gradle:docbook-reference-plugin:0.3.2") classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.2") @@ -141,6 +143,13 @@ configure(allprojects) { project -> repositories { mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } + maven { url "https://repository.tomitribe.com/content/groups/tomitribe/" + credentials { + username project.repoUser + password project.repoPassword + } + } + } dependencies { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java index 5b992184fe3e..d890d96c9cfa 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java @@ -242,6 +242,13 @@ private TypedValue createArray(ExpressionState state) throws EvaluationException FormatHelper.formatClassNameForMessage(intendedArrayType.getClass())); } String type = (String) intendedArrayType; + + if (state.getEvaluationContext().getConstructorResolvers().isEmpty()) { + // No constructor resolver -> no array construction either (as of 5.3.38) + throw new SpelEvaluationException(getStartPosition(), SpelMessage.CONSTRUCTOR_NOT_FOUND, + type + "[]", "[]"); + } + Class componentType; TypeCode arrayTypeCode = TypeCode.forName(type); if (arrayTypeCode == TypeCode.OBJECT) { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java index 255f485961f0..aea0133ddea9 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java @@ -18,8 +18,10 @@ import org.junit.Test; +import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.SimpleEvaluationContext; import static org.junit.Assert.*; @@ -106,6 +108,18 @@ public void multiDimensionalArray() { String[][][].class); } + @Test + public void noArrayConstruction() { + EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build(); + + try{ + parser.parseExpression("new int[2]").getValue(context); + } + catch(Exception e){ + assertTrue(e instanceof SpelEvaluationException); + } + } + @Test public void constructorInvocation03() { evaluateAndCheckError("new String[]", SpelMessage.MISSING_ARRAY_DIMENSION);