[ 
https://issues.apache.org/jira/browse/HDDS-8665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17724608#comment-17724608
 ] 

Tsz-wo Sze commented on HDDS-8665:
----------------------------------

HDDS-8665_bug.patch: applies to 8847b2c60bcdc831a7d515c414cd9c28bbf2bbf4 for 
showing the bug.

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



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