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

Optimize CorsConfiguration::checkHeaders #29853

Conversation

ThomHurks
Copy link
Contributor

In the checkHeaders method, if allowedHeaders contains * the result size can be requestHeaders.size(), but if this is not the case then the result size can only be as big as the minimum value of requestHeaders.size() and allowedHeaders.size(). requestHeaders.size() can be potentially big (user input) and allowedHeaders.size() could be small, so this saves memory in that case.

In the checkHeaders method, if allowedHeaders contains * the result
size can be requestHeaders.size(), but if this is not the case
then the result size can only be as big as the minimum value
of requestHeaders.size() and allowedHeaders.size().
requestHeaders.size() can be potentially big (user input) and
allowedHeaders.size() could be small, so this saves memory in
that case.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 19, 2023
@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Jan 19, 2023
@poutsma poutsma self-assigned this Jan 31, 2023
@poutsma poutsma added this to the 6.0.5 milestone Jan 31, 2023
@poutsma poutsma changed the title Small memory optimization in CorsConfiguration checkHeaders method Optimize CorsConfiguration::checkHeaders Jan 31, 2023
@poutsma poutsma removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 31, 2023
@poutsma poutsma closed this in aac1ed6 Jan 31, 2023
poutsma added a commit that referenced this pull request Jan 31, 2023
…ory-optimization

* gh-29853:
  Polish external contribution
  Optimize CorsConfiguration::checkHeaders
@ThomHurks ThomHurks deleted the cors-configuration-small-memory-optimization branch February 6, 2023 09:14
@ThomHurks
Copy link
Contributor Author

Thanks ❤️

mdeinum pushed a commit to mdeinum/spring-framework that referenced this pull request Jun 29, 2023
In the checkHeaders method, if allowedHeaders contains * the result
size can be requestHeaders.size(), but if this is not the case
then the result size can only be as big as the minimum value
of requestHeaders.size() and allowedHeaders.size().
requestHeaders.size() can be potentially big (user input) and
allowedHeaders.size() could be small, so this saves memory in
that case.

Closes spring-projectsgh-29853
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants