LiangliangSui commented on code in PR #1686:
URL: https://github.com/apache/fury/pull/1686#discussion_r1697956720


##########
java/fury-core/src/main/java/org/apache/fury/Fury.java:
##########
@@ -339,12 +341,14 @@ private void write(MemoryBuffer buffer, Object obj) {
       buffer.writeInt32(-1); // preserve 4-byte for nativeObjects start 
offsets.
     }
     // reduce caller stack
-    if (!refResolver.writeRefOrNull(buffer, obj)) {
+    boolean isNull = refResolver.writeRefOrNull(buffer, obj);
+    if (!isNull) {
       ClassInfo classInfo = classResolver.getOrUpdateClassInfo(obj.getClass());
       classResolver.writeClass(buffer, classInfo);
       writeData(buffer, classInfo, obj);
     }
-    if (shareMeta) {
+    MetaContext metaContext = getSerializationContext().getMetaContext();
+    if (shareMeta && !isNull && metaContext != null && 
!metaContext.writingClassDefs.isEmpty()) {

Review Comment:
   When obj is null, can we also not execute 
`classResolver.writeClassDefs(buffer)`?



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