Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "DiskImage" copy constructor #301

Merged
merged 2 commits into from
Jun 2, 2022

Commits on May 24, 2022

  1. core: redundant "Date" object's generation during Copy Constructor

    Some "Date" data members are copied using reference copying, while in
    some 3 places (without any visible reason) a new object is created.
    
    Changing for consistency to a simple reference copy: if we want to
    protect from changing an internal "Date" object via one of the
    containing "DiskImage" instances, we probably need to do it in
    many more places in this class (and other classes as well).
    
    Signed-off-by: Pavel Bar <pbar@redhat.com>
    barpavel committed May 24, 2022
    Configuration menu
    Copy the full SHA
    dd41bf1 View commit details
    Browse the repository at this point in the history
  2. core: fix the issue with fields being initialized twice during Copy C…

    …onstructor
    
    1. For some reason during Copy Constructor of the "DiskImage" class,
    the "CreationDate" & "LastModified" fields are overridden from having the
    correct date of the original "DiskImage", to the current date.
    
    2. Additionally there are 2 "ImageStatus" modifications: keeping the last one
    ("ImageStatus.LOCKED" status), since it's actually the one that matters.
    There is an open question whether all disks created with this Copy Constructor
    should always end up in "ImageStatus.LOCKED" status, but since the existing
    code might rely on this strange behavior and the investigation would take a
    lot of time, the decision was to keep the current behavior.
    
    This code was refactored lately in:
    https://gerrit.ovirt.org/c/ovirt-engine/+/117500/17/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/DiskImage.java#77
    
    But it looks like this implementation started long before - at 2012:
    https://gerrit.ovirt.org/c/ovirt-engine/+/3835/4/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java#350
    
    Signed-off-by: Pavel Bar <pbar@redhat.com>
    barpavel committed May 24, 2022
    Configuration menu
    Copy the full SHA
    33f796d View commit details
    Browse the repository at this point in the history