Skip to content

ZoneId property using ZoneRegion type hint cannot be read back #2307

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
IvanDanilau opened this issue Apr 19, 2022 · 1 comment
Closed

ZoneId property using ZoneRegion type hint cannot be read back #2307

IvanDanilau opened this issue Apr 19, 2022 · 1 comment
Assignees
Labels
type: bug A general bug

Comments

@IvanDanilau
Copy link

I have an entity with ZoneId property.
When I made parsing String value within ZoneId.of() method I've got ZoneRegion implementation class.
E.g Zone.of("Europe/Paris) -> ZoneRegion("Europe/Paris)
During the Writing entity everything goes fine and have next info in hashes:
3)"timezone"
4) "Europe/Paris"
5) "timezone._class"
6) "java.time.ZoneRegion"
Accordingly, when I try to read value - follow exception occurs:
ConverterNotFoundException: No converter found capable of converting from type [byte[]] to type [java.time.ZoneRegion]

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 19, 2022
@mp911de
Copy link
Member

mp911de commented Apr 20, 2022

Thanks for reporting the issue. The problem is on our side because we write a more concrete type hint (ZoneRegion instead of ZoneId) while we have only a converter for ZoneId registered. We can likely skip type hints on the reading side for types that are associated with a converter anyway as the persistent property provides sufficient details here.

@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 20, 2022
@mp911de mp911de self-assigned this Apr 20, 2022
@mp911de mp911de changed the title ZoneId property converting ZoneId property using ZoneRegion type hint cannot be read back Apr 20, 2022
@mp911de mp911de added this to the 2.6.5 (2021.1.5) milestone Apr 20, 2022
mp911de added a commit that referenced this issue Apr 20, 2022
We now try to eagerly apply a custom converter when reading Redis properties in the MappingRedisConverter before considering type hints from the hash.

We require type hints to properly restore the target type for a hash entry as Redis data is all byte arrays, so a simple String needs a type hint before we can load it back into an e.g. Object-typed property. Subtypes of properties (such as ZoneRegion for ZoneId) are sometimes not associated with a converter as only the parent type (ZoneId) is associated with a converter. Trying to convert the value into the subtype directly through our ConversionService would fail in that case.

Closes #2307
mp911de added a commit that referenced this issue Apr 20, 2022
We now try to eagerly apply a custom converter when reading Redis properties in the MappingRedisConverter before considering type hints from the hash.

We require type hints to properly restore the target type for a hash entry as Redis data is all byte arrays, so a simple String needs a type hint before we can load it back into an e.g. Object-typed property. Subtypes of properties (such as ZoneRegion for ZoneId) are sometimes not associated with a converter as only the parent type (ZoneId) is associated with a converter. Trying to convert the value into the subtype directly through our ConversionService would fail in that case.

Closes #2307
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

3 participants