Skip to content

Remove unnecessary code in SecurityExpressionRoot #7601

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

Closed
lee-ext opened this issue Nov 4, 2019 · 4 comments
Closed

Remove unnecessary code in SecurityExpressionRoot #7601

lee-ext opened this issue Nov 4, 2019 · 4 comments
Assignees
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Milestone

Comments

@lee-ext
Copy link
Contributor

lee-ext commented Nov 4, 2019

Code:

    private Set<String> getAuthoritySet() {
	if (roles == null) {
		roles = new HashSet<>();
		Collection<? extends GrantedAuthority> userAuthorities = authentication
				.getAuthorities();

		if (roleHierarchy != null) {
			userAuthorities = roleHierarchy
					.getReachableGrantedAuthorities(userAuthorities);
		}

		roles = AuthorityUtils.authorityListToSet(userAuthorities);
	}

	return roles;
}

The "roles = new HashSet<>();" is unnecessary and inefficiency.
Hope it can be modified.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 4, 2019
@lee-ext
Copy link
Contributor Author

lee-ext commented Nov 4, 2019

In line 161.

@eleftherias eleftherias self-assigned this Nov 6, 2019
@eleftherias eleftherias added in: core An issue in spring-security-core status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 6, 2019
@eleftherias
Copy link
Contributor

Thank you for the report @LeeHainie.
I agree that roles = new HashSet<>(); is unnecessary.
Are you interested in submitting a PR to remove it?

@lee-ext
Copy link
Contributor Author

lee-ext commented Nov 7, 2019

Yes, I'd love to.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 7, 2019
@eleftherias
Copy link
Contributor

Closed in 4b4c6e6.

@rwinch rwinch added type: enhancement A general enhancement and removed status: feedback-provided Feedback has been provided labels Nov 11, 2019
@rwinch rwinch added this to the 5.2.2 milestone Nov 11, 2019
@rwinch rwinch changed the title The problem in the org.springframework.security.access.expression.SecurityExpressionRoot Remove unnecessary code in SecurityExpressionRoot Nov 11, 2019
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

4 participants