Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpEL containing argument references not working in Spring Boot 3.2.0-RC2 #38470

Closed
ajujacob opened this issue Nov 21, 2023 · 3 comments
Closed
Labels
for: external-project For an external project and not something we can fix

Comments

@ajujacob
Copy link

SpEL expressions containing argument references (e.g., @PreAuthorize("@spELIssueDemoController.evaluateAccess(#allowAccess)")) throws the below exception in Spring Boot 3.2.0-RC2. This works without any issues in Spring Boot 3.1.5.

java.lang.IllegalArgumentException: Failed to evaluate expression '@spELIssueDemoController.evaluateAccess(#allowAccess)'
	at org.springframework.security.authorization.method.ReactiveExpressionUtils.lambda$evaluateAsBoolean$0(ReactiveExpressionUtils.java:41)

Here is a sample project that demonstrates this issue. Please refer to the README for more details about this issue and the steps to reproduce this issue.

A workaround for this issue is to add the "-parameters" flag during compilation. However, this isn't required in Spring Boot 3.1.5, which makes me believe it's a bug introduced in Spring Boot 3.2.0-RC2. Please let me know if you need more details.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 21, 2023
@philwebb

This comment was marked as outdated.

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2023
@philwebb philwebb added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 21, 2023
@wilkinsona
Copy link
Member

With Spring Boot 3.1.x (Framework 6.0), you will see a warning being logged like this:

16:01:49.222 [Test worker] WARN org.springframework.core.LocalVariableTableParameterNameDiscoverer -- Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: com.example.spelissuedemo.SPELIssueDemoUnitTest$ReactiveMethodSecuritySPELTestConfiguration$MyService

With Framework 6.1, compilation with -parameters is now required:

LocalVariableTableParameterNameDiscoverer has been removed in 6.1. Compile your Java sources with the common Java 8+ -parameters flag for parameter name retention (instead of relying on the -debug compiler flag) in order to be compatible with StandardReflectionParameterNameDiscoverer. With the Kotlin compiler, we recommend the -java-parameters flag.).

@ajujacob
Copy link
Author

Thank you, this is super helpful! I'll add the -parameters flag.

However, -parameters is unchecked by default in STS (4.20.1.RELEASE). Can we enable it by default in STS since it's required by the framework?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

4 participants