Skip to content

Enum properties fail to convert with constructor instantiation. #2213

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

Closed
michael-simons opened this issue Apr 8, 2021 · 0 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@michael-simons
Copy link
Collaborator

The MetaDataDrivenConversionService registers the EnumStringConverter with the delegate. However, the adapter created by Spring is then typed to java.lang.Enum, not to the correct enum.

For enum attributes we must use the concrete enum class when registering our converters.

@michael-simons michael-simons added this to the 5.3.9 (Neumann SR9) milestone Apr 8, 2021
@michael-simons michael-simons self-assigned this Apr 8, 2021
michael-simons added a commit that referenced this issue Apr 8, 2021
`Enum` properties always use an `AttributeConverter` and this is always passed to the parent conversion service. The parent conversion service however creates an adapter on the passed source type. Originally we passed `java.lang.Enum` here, leading to a scenario in which the parent decided to not be able to convert a concrete enum instance (and rightfully so). The solution in this commit is to pass the concrete field type if it is an enum.

The conversion failed only for constructor calls.

This fixes #2213.
michael-simons added a commit that referenced this issue Apr 8, 2021
`Enum` properties always use an `AttributeConverter` and this is always passed to the parent conversion service. The parent conversion service however creates an adapter on the passed source type. Originally we passed `java.lang.Enum` here, leading to a scenario in which the parent decided to not be able to convert a concrete enum instance (and rightfully so). The solution in this commit is to pass the concrete field type if it is an enum.

The conversion failed only for constructor calls.

This fixes #2213.
@michael-simons michael-simons added type: bug A general bug and removed bug labels Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant