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

ErrorAttributeOptions.excluding throws IllegalArgumentException if includes is empty #24153

Closed
bohnman opened this issue Nov 13, 2020 · 7 comments
Assignees
Labels
status: ideal-for-contribution An issue that a contributor can help us with status: superseded An issue that has been superseded by another type: bug A general bug

Comments

@bohnman
Copy link

bohnman commented Nov 13, 2020

The excluding method of ErrorAttributeOptions throws an IllegalArgumentException Collection is empty if its includes member field is empty.

Offending Code:

public ErrorAttributeOptions excluding(Include... excludes) {
		EnumSet<Include> updated = EnumSet.copyOf(this.includes);
		updated.removeAll(Arrays.asList(excludes));
		return new ErrorAttributeOptions(Collections.unmodifiableSet(updated));
	}

Notice that the including method handles the empty case correctly:

public ErrorAttributeOptions including(Include... includes) {
		EnumSet<Include> updated = (this.includes.isEmpty()) ? EnumSet.noneOf(Include.class)
				: EnumSet.copyOf(this.includes);
		updated.addAll(Arrays.asList(includes));
		return new ErrorAttributeOptions(Collections.unmodifiableSet(updated));
	}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 13, 2020
@bohnman bohnman changed the title ErrorAttributeOptions.excluding throws IllegalArgumentException of includes is empty ErrorAttributeOptions.excluding throws IllegalArgumentException if includes is empty Nov 13, 2020
@scottfrederick scottfrederick added the type: bug A general bug label Nov 13, 2020
@scottfrederick scottfrederick added this to the 2.3.x milestone Nov 13, 2020
@scottfrederick scottfrederick added status: ideal-for-contribution An issue that a contributor can help us with and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 13, 2020
@wanderleisouza
Copy link
Contributor

@scottfrederick how can I contribute on this? any process details/page link?

@scottfrederick
Copy link
Contributor

@wagnerluis1982 Thanks for the inquiry. There is some useful information in the project contributing guidelines to get started cloning and building the project.

This issue is assigned to the 2.3.x milestone, so you'll want to create your own fork of the project, create a new branch from the 2.3.x branch, commit your changes to the new branch, and submit the pull request against 2.3.x. We'll take care of merging the changes into master from there.

ErrorAttributeOptions doesn't currently have its own tests, but is tested indirectly through DefaultErrorAttributes. It would be good to add a new ErrorAttributesOptionsTests test case to verify this problem and the fix.

Feel free to ask any other questions here.

@wagnerluis1982
Copy link
Contributor

Scott, I suppose you meant @wanderleisouza 😏

@amit-github-personal
Copy link

@scottfrederick , I've already signed CLA. Can I work on this issue?

@scottfrederick
Copy link
Contributor

@amit-github-personal The issue was first claimed by @wanderleisouza, so let's give them a chance to work on it.

@wanderleisouza
Copy link
Contributor

@scottfrederick I just sent a pull request #24230 with testes and bug-fix, let me know if everything is correct. Thank you for entire support.

@snicoll
Copy link
Member

snicoll commented Nov 23, 2020

Closing in favour of PR #24230

@snicoll snicoll closed this as completed Nov 23, 2020
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Nov 23, 2020
@snicoll snicoll removed this from the 2.3.x milestone Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with status: superseded An issue that has been superseded by another type: bug A general bug
Projects
None yet
Development

No branches or pull requests

7 participants