dosubot[bot] commented on issue #3013: URL: https://github.com/apache/hugegraph/issues/3013#issuecomment-4380257320
<!-- Answer --> Your analysis is correct. The root cause is that all backend serializers (Text, Binary, MySQL, Cassandra) deserialize userdata using `JsonUtil.fromJson(userdataStr, Map.class)`, which gives Jackson no type information about the values [[1]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/TextSerializer.java) [[2]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java) [[3]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-mysql/src/main/java/org/apache/hugegraph/backend/store/mysql/MysqlSerializer.java) [[4]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-cassandra/src/main/java/org/apache/hugegraph/backend/st ore/cassandra/CassandraSerializer.java). Even though a custom `DateDeserializer` is registered with format `"yyyy-MM-dd HH:mm:ss.SSS"` [[5]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/HugeGraphSONModule.java), it's only invoked when the target type is explicitly `Date.class` — not when deserializing to a raw `Map`. During creation, `SchemaTransaction.setCreateTimeIfNeeded()` correctly stores a real `java.util.Date` via `DateUtil.now()` [[6]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransaction.java#L87-L91), and the serialization side properly converts it to a formatted string. But on the read path, the string is never converted back. The simplest fix would be to post-process userdata after deserialization — check for the `~create_time` key and convert the `String` value back to `Date` using `DateUtil.parse()` [[7]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/DateUtil.java#L32-L51). This would need to be applied in the `readUserdata()` path of each serializer (or in a shared utility). Multiple test cases already expect a `Date` return type and would throw `ClassCastException` otherwise [[8]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/VertexLabelCoreTest.java#L1220) [[9]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/PropertyKeyCoreTest.java#L669). Worth noting: this bug likely existed before PR #3011 but was rarely observed in single-JVM deployments because the in-memory schema object (with the correct `Date` type) was typically used without needing a full backend reload. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).* --- Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fhugegraph). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fhugegraph&message_id=78c4b1b3-5e7d-4e08-bb80-9f17432626c5) [](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fhugegraph) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fhugegraph) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
