chaokunyang commented on code in PR #1701:
URL: https://github.com/apache/fury/pull/1701#discussion_r1670421855
##########
java/fury-core/src/main/java/org/apache/fury/Fury.java:
##########
@@ -1220,6 +1240,47 @@ public Object
deserializeJavaObjectAndClass(FuryReadableChannel channel) {
return deserializeJavaObjectAndClass(buf);
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T copy(T obj) {
+ if (Objects.isNull(obj)) {
+ return null;
+ }
+ try {
+ if (obj instanceof FuryCopyable) {
+ return (T) ((FuryCopyable<?>) obj).copy(this);
+ } else {
+ return (T)
classResolver.getOrUpdateClassInfo(obj.getClass()).getSerializer().copy(obj);
+ }
+ } catch (StackOverflowError e) {
+ throw processCopyStackOverflowError(e);
+ } finally {
+ if (copyRefTracking && copyDepth == 0) {
+ resetCopy();
+ }
+ }
+ }
+
+ /**
+ * Record the mapping between the object currently being copied and the
newly generated object
+ * after copying.
+ *
+ * @param originObj the origin object instance
+ * @param newObj the new object instance
+ */
+ public void copyReference(Object originObj, Object newObj) {
+ if (Objects.nonNull(originObj) && Objects.nonNull(newObj)) {
Review Comment:
Why not just write `originObj != null && newObj != null`? And for ref
tracking, I think checking originObj is enough
--
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]