Skip to content

Remove unnecessary code in SecurityExpressionRoot #7635

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

Merged
merged 2 commits into from
Nov 7, 2019
Merged

Remove unnecessary code in SecurityExpressionRoot #7635

merged 2 commits into from
Nov 7, 2019

Conversation

lee-ext
Copy link
Contributor

@lee-ext lee-ext commented Nov 7, 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.

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.
Remove unused imports
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 7, 2019
@eleftherias eleftherias self-assigned this Nov 7, 2019
@eleftherias eleftherias merged commit 4b4c6e6 into spring-projects:master Nov 7, 2019
@eleftherias eleftherias added in: core An issue in spring-security-core and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 7, 2019
@rwinch rwinch added the type: enhancement A general enhancement label Nov 11, 2019
@rwinch rwinch added this to the 5.2.2 milestone Nov 11, 2019
@rwinch rwinch changed the title Remove unnecessary and inefficiency code Remove unnecessary code in SecurityExpressionRoot Nov 11, 2019
@rwinch rwinch added the status: duplicate A duplicate of another issue label 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 status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants