[ 
https://issues.apache.org/jira/browse/HDDS-8665?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tsz-wo Sze updated HDDS-8665:
-----------------------------
    Description: OmDBSnapshotInfoCodec.copyObject(..) is a shallow copy -- it 
simply returns the same object.  However, if it is changed to return a deep 
copy as shown in the second comment, TestOMSnapshotDeleteRequest and 
TestOMSnapshotPurgeRequestAndResponse will fail.  These two tests depend on the 
behavior that, after copying, changing one copy will also change the other 
copy.  (was: OmDBSnapshotInfoCodec.copyObject(..) is a shallow copy -- it 
simply returns the same object.  However, if it is changed to return a deep 
copy as below, TestOMSnapshotDeleteRequest and 
TestOMSnapshotPurgeRequestAndResponse will fail.  These two tests depend on the 
behavior that, after copying, changing one copy will also change the other copy.
{code}
+++ 
b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/codec/OmDBSnapshotInfoCodec.java
@@ -52,7 +52,13 @@ public SnapshotInfo fromPersistedFormat(byte[] rawData)
 
   @Override
   public SnapshotInfo copyObject(SnapshotInfo object) {
-    // Note: Not really a "copy". from OMDBSnapshotInfoCodec
-    return object;
+    // FIXME: Deep copy will cause failures
+    //        - TestOMSnapshotDeleteRequest NullPointerException
+    //        - TestOMSnapshotPurgeRequestAndResponse AssertionFailedError
+    try {
+      return fromPersistedFormat(toPersistedFormat(object));
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
+    }
   }
 }{code}
)

> OmDBSnapshotInfoCodec.copyObject(..) does not follow the general contract of 
> copy.
> ----------------------------------------------------------------------------------
>
>                 Key: HDDS-8665
>                 URL: https://issues.apache.org/jira/browse/HDDS-8665
>             Project: Apache Ozone
>          Issue Type: Bug
>          Components: OM, Snapshot
>            Reporter: Tsz-wo Sze
>            Priority: Major
>         Attachments: HDDS-8665_bug.patch
>
>
> OmDBSnapshotInfoCodec.copyObject(..) is a shallow copy -- it simply returns 
> the same object.  However, if it is changed to return a deep copy as shown in 
> the second comment, TestOMSnapshotDeleteRequest and 
> TestOMSnapshotPurgeRequestAndResponse will fail.  These two tests depend on 
> the behavior that, after copying, changing one copy will also change the 
> other copy.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to