Skip to content

Commit

Permalink
Merge pull request #6 from cesarhernandezgt/v.4.3.30.RELEASE-TT.x-patch
Browse files Browse the repository at this point in the history
Fix build and spring-expression ConstructorReference
  • Loading branch information
cesarhernandezgt authored Aug 20, 2024
2 parents 987092f + 8dfcb0f commit 93b3572
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 93b3572

Please sign in to comment.