Skip to content

Commit bb0cfd3

Browse files
author
Tom Gottfried
committed
Fix serializing java.sql.Timestamp
SqlTimestampSerializer missed to override toTemporalAccessor, leading to ClassCastExceptions in the default implementation in AbstractDateSerializer. Since it does all formatting after calling toInstant on the value, we can safely use the same code path as is used for java.util.Date (despite what is said about the inheritance relationship between Date and Timestamp in their API documentation). Closes #687.
1 parent 93eefea commit bb0cfd3

File tree

2 files changed

+1
-44
lines changed

2 files changed

+1
-44
lines changed

src/main/java/org/eclipse/yasson/internal/serializer/types/SqlTimestampSerializer.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/main/java/org/eclipse/yasson/internal/serializer/types/TypeSerializers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class TypeSerializers {
121121
if (isClassAvailable("java.sql.Date")) {
122122
cache.put(Date.class, SqlDateSerializer::new);
123123
cache.put(java.sql.Date.class, SqlDateSerializer::new);
124-
cache.put(java.sql.Timestamp.class, SqlTimestampSerializer::new);
124+
cache.put(java.sql.Timestamp.class, SqlDateSerializer::new);
125125
}
126126
SERIALIZERS = Map.copyOf(cache);
127127

0 commit comments

Comments
 (0)