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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoUniqueBeanDefinitionException should make sure beansNameFound is serializable #29753

Conversation

perlun
Copy link
Contributor

@perlun perlun commented Dec 29, 2022

Seen in Spring 5.3.18. LinkedHashMap.keySet() tends to return a java.util.LinkedHashMap$LinkedKeySet instance, which is not serializable. This becomes a problem then when you e.g. try to propagate the NoUniqueBeanDefinitionException error across a network boundary (our use case).

Wrapping these in HashSets seem like the simplest way around. The only other call site was passing in an Arrays.asList() object, and asList is explicitly defined to return a serializable list.

(If this change is considered good/safe, it would perhaps be worth back-porting this to the Spring 5 branch as well. It does indeed change the semantics, but it could also arguably be considered a back-port safe bug fix.)

Thanks for a great project! 馃檹

@pivotal-cla
Copy link

@perlun Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 29, 2022
@pivotal-cla
Copy link

@perlun Thank you for signing the Contributor License Agreement!

@perlun perlun force-pushed the fix/use-serializable-set-in-exception branch from d580f3f to 5cd200b Compare December 29, 2022 13:19
@perlun
Copy link
Contributor Author

perlun commented Dec 30, 2022

(Test failure seems unrelated to me. 馃)

@rstoyanchev rstoyanchev added the in: core Issues in core modules (aop, beans, core, context, expression) label Jan 24, 2023
@snicoll snicoll changed the title Fix usage of NoUniqueBeanDefinitionException to be serializable NoUniqueBeanDefinitionException should make sure beansNameFound is serializable Aug 27, 2023
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 27, 2023
@snicoll snicoll self-assigned this Aug 27, 2023
@snicoll snicoll added this to the 6.0.12 milestone Aug 27, 2023
@snicoll snicoll closed this in 1af259f Aug 27, 2023
@snicoll
Copy link
Member

snicoll commented Aug 27, 2023

Thanks again @perlun and that's a good catch. Rather than doing this at the caller level, I've fixed the exception itself so that it creates a copy of the collection. This is similar to what we do for arrays.

@perlun perlun deleted the fix/use-serializable-set-in-exception branch August 28, 2023 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants