funky-eyes commented on code in PR #8160:
URL: https://github.com/apache/incubator-seata/pull/8160#discussion_r3567642667


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/parser/Fastjson2UndoLogParser.java:
##########
@@ -75,6 +76,10 @@ public byte[] encode(BranchUndoLog branchUndoLog) {
 
     @Override
     public BranchUndoLog decode(byte[] bytes) {
-        return JSONB.parseObject(bytes, BranchUndoLog.class, 
jsonReaderFeature);
+        // JSONB initializes readers in the shared provider lazily. 
Synchronization prevents $ref fields from being lost
+        // when fastjson2 initializes readers concurrently.
+        synchronized (JSONFactory.class) {

Review Comment:
   Please replace synchronized with a Lock



##########
serializer/seata-serializer-fastjson2/src/main/java/org.apache.seata.serializer.fastjson2/Fastjson2Serializer.java:
##########
@@ -30,10 +31,14 @@ public <T> byte[] serialize(T t) {
 
     @Override
     public <T> T deserialize(byte[] bytes) {
-        return (T) JSONB.parseObject(
-                bytes,
-                Object.class,
-                Fastjson2SerializerFactory.getInstance().getFilter(),
-                
Fastjson2SerializerFactory.getInstance().getJsonReaderFeatureList());
+        // JSONB initializes readers in the shared provider lazily. 
Synchronization prevents $ref fields from being lost
+        // when fastjson2 initializes readers concurrently.
+        synchronized (JSONFactory.class) {

Review Comment:
   Please replace synchronized with a Lock



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