Skip to content

Jsr310Converters does not contain converters for OffsetTime and OffsetDateTime #2677

Closed
@DeltaIII

Description

@DeltaIII

When using spring-data-redis and RedisSerializer.java() I noticed that a field of type OffsetTime wasn't being serialised even though it implements Serializable. The root cause is that SimpleTypeHolder assumes that any class that starts with java.time is a simple type (which in turn means CustomConversions.isSimpleType(OffsetTime.class) == true). This breaks the assumption that CustomConversions has a converter for the type as per the javadoc:

Returns whether the given type is considered to be simple. That means it's either a general simple type or we have a writing Converter registered for a particular type.

Expected behaviour:

  • customConversions.isSimpleType returns false if there are no converters for OffsetDateTime or OffsetTime

Actual behaviour:

  • customConversions.isSimpleType(OffsetDateTime.class) == true even if there are no converters for OffsetDateTime (and for OffsetTime

Relevant Code links:
https://github.com/spring-projects/spring-data-commons/blob/541f0ced32f3f8b2143ea5b793a489828567ff13/src/main/java/org/springframework/data/mapping/model/SimpleTypeHolder.java#L158

https://github.com/spring-projects/spring-data-commons/blob/541f0ced32f3f8b2143ea5b793a489828567ff13/src/main/java/org/springframework/data/convert/CustomConversions.java#L190

Metadata

Metadata

Assignees

Labels

in: mappingMapping and conversion infrastructuretype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions