Skip to content

Regression: SpEL expression with Arrays.asList and empty array [SPR-12522] #17127

@spring-projects-issues

Description

@spring-projects-issues

Elias opened SPR-12522 and commented

Please see the code attached.

When a config variable is empty from a properties file and trying to convert it in a list of strings, spell cannot evaluate the expression. This code works in Spring 3.2.6. The output should be an empty list.

Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1029E:(pos 20): A problem occurred when trying to execute method 'asList' on object of type 'java.lang.Class': 'Problem invoking method: public static java.util.List java.util.Arrays.asList(java.lang.Object[])'
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:164) ~[spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1362) ~[spring-beans-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:964) ~[spring-beans-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949) ~[spring-beans-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:816) ~[spring-beans-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:744) ~[spring-beans-4.1.2.RELEASE.jar:4.1.2.RELEASE]
... 62 common frames omitted
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1029E:(pos 20): A problem occurred when trying to execute method 'asList' on object of type 'java.lang.Class': 'Problem invoking method: public static java.util.List java.util.Arrays.asList(java.lang.Object[])'
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:136) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:49) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:342) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:161) ~[spring-context-4.1.2.RELEASE.jar:4.1.2.RELEASE]
... 67 common frames omitted
Caused by: org.springframework.expression.AccessException: Problem invoking method: public static java.util.List java.util.Arrays.asList(java.lang.Object[])
at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:116) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:129) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
... 73 common frames omitted
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.springframework.expression.spel.support.ReflectionHelper.isFirstEntryInArray(ReflectionHelper.java:350) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.support.ReflectionHelper.convertArguments(ReflectionHelper.java:285) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:106) ~[spring-expression-4.1.2.RELEASE.jar:4.1.2.RELEASE]
... 74 common frames omitted

Affects: 4.1.2

Attachments:

Issue Links:

Referenced from: commits fa138d2

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions