Skip to content

AutoConfigurationImportSelector#getExcludes doesn't use asList consistently #32102

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
Double-Jun opened this issue Aug 17, 2022 · 1 comment
Closed
Assignees
Labels
type: task A general task
Milestone

Comments

@Double-Jun
Copy link

Version: 2.7.2

When reading the AutoConfigurationImportSelector class, the getExclusions method is a bit confusing, there are two different ways to get an array of strings from AnnotationAttributes based on attribute names.

The source code is as follows:

protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
	Set<String> excluded = new LinkedHashSet<>();
	excluded.addAll(asList(attributes, "exclude"));
	excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName")));
	excluded.addAll(getExcludeAutoConfigurationsProperty());
	return excluded;
}

protected final List<String> asList(AnnotationAttributes attributes, String name) {
    String[] value = attributes.getStringArray(name);
    return Arrays.asList(value);
}

Is it possible to do the same way, for example like below:

protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
    Set<String> excluded = new LinkedHashSet<>();
    excluded.addAll(Arrays.asList(attributes.getStringArray("exclude")));
    excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName")));
    excluded.addAll(getExcludeAutoConfigurationsProperty());
    return excluded;
}

This is not a problem and can of course be ignored.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 17, 2022
@snicoll snicoll changed the title Not a issue, just to make the code cleaner. AutoConfigurationImportSelector#getExcludes doesn't use asList consistently Aug 17, 2022
@snicoll snicoll added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 17, 2022
@snicoll snicoll added this to the 2.6.11 milestone Aug 17, 2022
@snicoll snicoll self-assigned this Aug 17, 2022
@philwebb
Copy link
Member

Thanks @Double-Jun, I like the consistency of always using the same method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants