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

Remove internal Optional usage in favor of null checks #7155

Closed
rwinch opened this issue Jul 26, 2019 · 3 comments · Fixed by #7295

Comments

@rwinch
Copy link
Member

commented Jul 26, 2019

Summary

While some prefer the readability of using the Optional API, the GC overhead of creating additional objects (including intermediate objects) can cause significant decrease in performance There are some simple benchmarks that illustrate the problem.

We should replace Stream usage with for loops throughout Spring Security's code base.

Related gh-7154

@eddumelendez

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2019

Hi @rwinch, do you think this is good for first-timers-only?

@rwinch

This comment has been minimized.

Copy link
Member Author

commented Aug 5, 2019

Thanks for asking @eddumelendez I think it is likely a lot of code to touch for a first timers.

@rwinch rwinch changed the title Remove internal Optional usage in favor of null checksgtgt Remove internal Optional usage in favor of null checks Aug 9, 2019

watsta added a commit to watsta/spring-security that referenced this issue Aug 22, 2019
watsta added a commit to watsta/spring-security that referenced this issue Aug 22, 2019
Merge branches 'spring-projectsgh-7155-remove-optional-usage' and 'ma…
…ster' of https://github.com/watsta/spring-security into spring-projectsgh-7155-remove-optional-usage

# Conflicts:
#	oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunction.java
eleftherias added a commit that referenced this issue Aug 26, 2019
@eleftherias

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

As mentioned in the PR, Optional is still being used in the following files:

  • org.springframework.security.oauth2.client.web.reactive.function.client.OAuth2AuthorizedClientResolver
  • org.springframework.security.oauth2.client.web.reactive.result.method.annotation.OAuth2AuthorizedClientResolver
  • org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction
    Since an additional object needs to be created regardless, in this situation, it is reasonable to keep using Optionals instead of creating an object of a different type.

@eleftherias eleftherias self-assigned this Aug 26, 2019

@eleftherias eleftherias added this to the 5.2.0.RC1 milestone Aug 26, 2019

kostya05983 added a commit to kostya05983/spring-security that referenced this issue Aug 26, 2019
fhanik added a commit to fhanik/spring-security that referenced this issue Aug 27, 2019
kostya05983 added a commit to kostya05983/spring-security that referenced this issue Aug 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.