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));
}
Comment From: wanderleisouza
@scottfrederick how can I contribute on this? any process details/page link?
Comment From: scottfrederick
@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.
Comment From: wagnerluis1982
Scott, I suppose you meant @wanderleisouza :smirk:
Comment From: amit-github-personal
@scottfrederick , I've already signed CLA. Can I work on this issue?
Comment From: scottfrederick
@amit-github-personal The issue was first claimed by @wanderleisouza, so let's give them a chance to work on it.
Comment From: wanderleisouza
@scottfrederick I just sent a pull request https://github.com/spring-projects/spring-boot/pull/24230 with testes and bug-fix, let me know if everything is correct. Thank you for entire support.
Comment From: snicoll
Closing in favour of PR #24230