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-issuemaster opened this issue Nov 28, 2014 · 5 comments
Closed

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

spring-issuemaster opened this issue Nov 28, 2014 · 5 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster 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:

  • #17142 CollectionFactory API is not type-safe ("is depended on by")
  • DATACMNS-613 Remove custom CollectionFactory once we migrate to Spring 4.1.x
  • #17138 CollectionFactory should create empty EnumSets and EnumMaps

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

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 28, 2014

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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 28, 2014

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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 29, 2014

geert commented

Thanks Juergen. Works like a charm.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 9, 2014

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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.