[GitHub] rhtyd commented on a change in pull request #2567: [Vmware] Fix for OVF parsing error
rhtyd commented on a change in pull request #2567: [Vmware] Fix for OVF parsing error URL: https://github.com/apache/cloudstack/pull/2567#discussion_r181346949 ## File path: api/src/com/cloud/agent/api/storage/OVFHelper.java ## @@ -113,7 +113,7 @@ public static Long getDiskVirtualSize(Long capacity, String allocationUnits, Str String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits"); od._diskId = disk.getAttribute("ovf:diskId"); od._fileRef = disk.getAttribute("ovf:fileRef"); -od._populatedSize = Long.parseLong(disk.getAttribute("ovf:populatedSize") == null ? "0" : disk.getAttribute("ovf:populatedSize")); +od._populatedSize = NumberUtils.toLong(disk.getAttribute("ovf:populatedSize")); Review comment: @DaanHoogland let's kick tests both on master and 4.11 over the weekend. I don't think Nicolas's pr will cause any fail, besides Travis and pkging has passed. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] rhtyd commented on a change in pull request #2567: [Vmware] Fix for OVF parsing error
rhtyd commented on a change in pull request #2567: [Vmware] Fix for OVF parsing error URL: https://github.com/apache/cloudstack/pull/2567#discussion_r18138 ## File path: api/src/com/cloud/agent/api/storage/OVFHelper.java ## @@ -113,7 +113,7 @@ public static Long getDiskVirtualSize(Long capacity, String allocationUnits, Str String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits"); od._diskId = disk.getAttribute("ovf:diskId"); od._fileRef = disk.getAttribute("ovf:fileRef"); -od._populatedSize = Long.parseLong(disk.getAttribute("ovf:populatedSize") == null ? "0" : disk.getAttribute("ovf:populatedSize")); +od._populatedSize = NumberUtils.toLong(disk.getAttribute("ovf:populatedSize")); Review comment: @DaanHoogland cool, I did not know that internally it falls to ` NumberUtils.toLong(String,0L)` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] rhtyd commented on a change in pull request #2567: [Vmware] Fix for OVF parsing error
rhtyd commented on a change in pull request #2567: [Vmware] Fix for OVF parsing error URL: https://github.com/apache/cloudstack/pull/2567#discussion_r181338037 ## File path: api/src/com/cloud/agent/api/storage/OVFHelper.java ## @@ -113,7 +113,7 @@ public static Long getDiskVirtualSize(Long capacity, String allocationUnits, Str String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits"); od._diskId = disk.getAttribute("ovf:diskId"); od._fileRef = disk.getAttribute("ovf:fileRef"); -od._populatedSize = Long.parseLong(disk.getAttribute("ovf:populatedSize") == null ? "0" : disk.getAttribute("ovf:populatedSize")); +od._populatedSize = NumberUtils.toLong(disk.getAttribute("ovf:populatedSize")); Review comment: @nvazquez this can cause exception still -- this should be used with a default value like `0L` in case of error. For example like this -- `NumberUtils.toLong("string-param", 0L) `. Also no tests were ran /cc @DaanHoogland This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services