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

Default conversion support for EnumSet / EnumMap [SPR-12483] #17089

Closed
spring-projects-issues opened this issue Nov 28, 2014 · 5 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 28, 2014

geert opened SPR-12483 and commented

Default converters cannot handle EnumSets. A form object with a EnumSet property throws an exception.

Failed to convert property value of type java.lang.String[] to required type java.util.EnumSet for property typeProjecten; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String[] to type @org.hibernate.validator.constraints.NotEmpty java.util.EnumSet<@org.hibernate.validator.constraints.NotEmpty nl.amc.mb.amcliteratuur.domain.TypeProject> for value {CAT, CONFERENCE}; nested exception is java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.EnumSet

This issue has been resolved in Spring DATA MongoDB (https://jira.spring.io/browse/DATAMONGO-833). It would be nice if it was solved in Spring Framework itself


Affects: 3.2.12

Issue Links:

Referenced from: commits aec284a, bfbd25a, 7635e7b, fef4cd0

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've added support for EnumSet / EnumMap to our core CollectionFactory, with an overloaded createCollection/Map method taking an element/key type into account if known. All applicable default converters use the overloaded variant now, automatically being able to handle EnumSet / EnumMap that way.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This is available in the latest 4.1.3 snapshot in the meantime. Feel free to give it an early try...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

geert commented

Thanks Juergen. Works like a charm.

@spring-projects-issues
Copy link
Collaborator Author

Oliver Drotbohm commented

Juergen Hoeller - Is this a potential candidate fro back-porting into the 4.0.x timeline? If so, we could drop our custom CollectionFactory with the upcoming Spring Data release train.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 10, 2014

Sam Brannen commented

See also: #17138

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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants