dpol1 commented on code in PR #3026:
URL: https://github.com/apache/hugegraph/pull/3026#discussion_r3258000847


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/Userdata.java:
##########
@@ -34,7 +35,31 @@ public Userdata() {
     }
 
     public Userdata(Map<String, Object> map) {
-        this.putAll(map);
+        for (Map.Entry<String, Object> e : map.entrySet()) {
+            this.put(e.getKey(), normalizeValue(e.getKey(), e.getValue()));
+        }
+    }
+
+    /**
+     * Normalize internal userdata values whose runtime type can diverge from
+     * their serialized form. The only such key today is {@link #CREATE_TIME}:
+     * it is written as a {@link java.util.Date} but persisted as a formatted
+     * JSON string by the backend serializers, and Jackson cannot re-type a
+     * value to {@code Date} when the target is a raw {@code Map}. This method
+     * restores the original type after deserialization. Idempotent for values
+     * already of the expected type.
+     */
+    public static Object normalizeValue(String key, Object value) {

Review Comment:
   Done. `Userdata` now overrides `put()` (and `putAll()`, since HashMap's
     `putAll` skips the overridden `put`):
   
     ```java
     @Override
     public Object put(String key, Object value) {
         return super.put(key, normalizeValue(key, value));
     }
   
     So a raw new Userdata().put(CREATE_TIME, "...") is normalized too, not
     just the Map constructor.
   



-- 
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]

Reply via email to