Skip to content

Commit

Permalink
Make the OvfOvirtReader disk read more robust
Browse files Browse the repository at this point in the history
Some OVA files might miss one (or more) of the attributes. This might
result in NullPointerException. This change will make the disk read to
be more robust and prevent the exception.

Signed-off-by: Liran Rotenberg <lrotenbe@redhat.com>
  • Loading branch information
liranr23 committed Nov 14, 2023
1 parent 504baab commit 5faa9f8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ public void buildDisk() {
protected void readDisk(XmlNode node, DiskImage image) {
super.readDisk(node, image);

if (!StringUtils.isEmpty(node.attributes.get("ovf:size").getValue())) {
if (node.attributes.get("ovf:size") != null && !StringUtils.isEmpty(node.attributes.get("ovf:size").getValue())) {
image.setSize(convertGigabyteToBytes(Long.parseLong(node.attributes.get("ovf:size").getValue())));
}
if (!StringUtils.isEmpty(node.attributes.get("ovf:actual_size").getValue())) {
if (node.attributes.get("ovf:actual_size") != null && !StringUtils.isEmpty(node.attributes.get("ovf:actual_size").getValue())) {
image.setActualSizeInBytes(
convertGigabyteToBytes(Long.parseLong(node.attributes.get("ovf:actual_size").getValue())));
}
Expand Down

0 comments on commit 5faa9f8

Please sign in to comment.