Skip to content

Unable to resolve methods with variable number of arguments in SpEL [DATACMNS-1518] #1948

@spring-projects-issues

Description

@spring-projects-issues

Patrice Blanchardie opened DATACMNS-1518 and commented

As explained in https://stackoverflow.com/questions/35486538/how-to-user-hasanyrole-like-expression-spel-in-query, we're not able to use hasAnyRole/hasAnyAuthority.

org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 0): Method call: Method hasAnyRole(java.lang.String,java.lang.String) cannot be found on java.lang.Object[] type
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMetho

The ExtensionAwareEvaluationContextProvider MethodResolver doesn't match hasAnyRole(String[]), and the ReflectiveMethodResolver has a weird targetObject so its doesn't find anything.

When used elsewhere (eg. in @PreAuthorize anotations, only ReflectiveMethodResolver is used with targetObject MethodSecurityExpressionRoot, and the method is properly resolved


Affects: 2.0.14 (Kay SR14), 2.1.6 (Lovelace SR6), 2.2 M3 (Moore), 1.13.20 (Ingalls SR20)

Backported to: 2.1.7 (Lovelace SR7)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions