Tomas Jelinek has uploaded a new change for review. Change subject: restapi: fix NPE on vm statistics ......................................................................
restapi: fix NPE on vm statistics The problem was that the getMigrationProgressPercent can return null, but this case was not handled and the setting to long throw a NPE. Fixed by explicitly handling the null. Change-Id: Iee06e42c33a6ade371a84deb89d459586d82a9c3 Bug-Url: https://bugzilla.redhat.com/1103490 Signed-off-by: Tomas Jelinek <[email protected]> --- M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/VmStatisticalQuery.java 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/28342/1 diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/VmStatisticalQuery.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/VmStatisticalQuery.java index 176dbfb..64c3681 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/VmStatisticalQuery.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/VmStatisticalQuery.java @@ -29,6 +29,8 @@ VmStatistics s = entity.getStatisticsData(); long mem = entity.getMemSizeMb() * Mb; long memUsedByCent = s.getusage_mem_percent()==null ? 0 : mem * s.getusage_mem_percent(); + long migrationProgress = entity.getMigrationProgressPercent() != null ? entity.getMigrationProgressPercent() : 0; + Double zero = 0.0; Double cpuUser = s.getcpu_user()==null ? zero : s.getcpu_user(); Double cpuSys = s.getcpu_sys()==null ? zero : s.getcpu_sys(); @@ -37,7 +39,7 @@ setDatum(clone(CPU_GUEST), cpuUser), setDatum(clone(CPU_OVERHEAD), cpuSys), setDatum(clone(CPU_TOTAL), cpuUser + cpuSys), - setDatum(clone(MIGRATION_PROGRESS), entity.getMigrationProgressPercent())); + setDatum(clone(MIGRATION_PROGRESS), migrationProgress)); } public Statistic adopt(Statistic statistic) { -- To view, visit http://gerrit.ovirt.org/28342 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iee06e42c33a6ade371a84deb89d459586d82a9c3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
