Skip to content

Improve AbstractSecurityExpressionHandler performance #5622

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

Open
dreis2211 opened this issue Aug 1, 2018 · 1 comment
Open

Improve AbstractSecurityExpressionHandler performance #5622

dreis2211 opened this issue Aug 1, 2018 · 1 comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement

Comments

@dreis2211
Copy link
Contributor

Summary

AbstractSecurityExpressionHandler creates new StandardEvaluationContext instances over and over, thus leading to a performance penalty in WebExpressionVoter that could be avoided imho. See https://jira.spring.io/browse/SPR-16942 and its linked tickets for more information.

Actual Behavior

AbstractSecurityExpressionHandler creates new StandardEvaluationContext instances over and over.

Expected Behavior

EvaluationContext instances are cached and the use of SimpleEvaluationContext is considered (if applicable).

Versions

This affects the 4.2.x mainline, but presumably 5.x as well.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 7, 2019
@jzheaux jzheaux changed the title Improve WebExpressionVoter performance Improve AbstractSecurityExpressionHandler performance Apr 10, 2023
@jzheaux
Copy link
Contributor

jzheaux commented Apr 10, 2023

Thanks for the report, @dreis2211. AbstractSecurityExpressionHandler currently recreates the context on each evaluation because a SecurityExpressionRoot(Authentication) is the root object and Authentication is a method parameter.

I read the referenced issue and I agree that a context-bound root object would hypothetically address the issue, but I'm not clear on how to achieve that in a thread-safe way in this case. The Authentication method parameter would somehow need to be installed in a thread-safe location that the StandardEvaluationContext accesses.

@jzheaux jzheaux added in: core An issue in spring-security-core type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants