Martin Peřina has uploaded a new change for review. Change subject: core: Fix NPE in VdsArchitectureHelper ......................................................................
core: Fix NPE in VdsArchitectureHelper Fixes NullPointerException in VdsArchitectureHelper which can occur if we try to test fence agent settings for a new host which was not yet saved in database. Change-Id: I361c930d01a17da8bc1085286fdb845af0b5c237 Bug-Url: https://bugzilla.redhat.com/1182510 Signed-off-by: Martin Perina <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java 1 file changed, 7 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/63/38963/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java index 663d47f..b052b6b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsArchitectureHelper.java @@ -23,12 +23,14 @@ public ArchitectureType getArchitecture(VdsStatic host) { VDSGroup cluster = DbFacade.getInstance().getVdsGroupDao().get(host.getVdsGroupId()); VdsDynamic vdsDynamic = DbFacade.getInstance().getVdsDynamicDao().get(host.getId()); - ServerCpu cpu = CpuFlagsManagerHandler.findMaxServerCpuByFlags(vdsDynamic.getCpuFlags(), - cluster.getCompatibilityVersion()); - if (cpu != null && cpu.getArchitecture() != null) { - return cpu.getArchitecture(); + if (vdsDynamic != null) { + ServerCpu cpu = CpuFlagsManagerHandler.findMaxServerCpuByFlags(vdsDynamic.getCpuFlags(), + cluster.getCompatibilityVersion()); + if (cpu != null && cpu.getArchitecture() != null) { + return cpu.getArchitecture(); + } } - // take architecture from the cluster if it is null on the host level + // take architecture from the cluster if it is null on the host level or host is not yet saved in db log.info("Failed to get architecture type from host information for host '{}'. Using cluster '{}' architecture value instead.", host.getName(), cluster.getName()); return cluster.getArchitecture(); } -- To view, visit https://gerrit.ovirt.org/38963 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I361c930d01a17da8bc1085286fdb845af0b5c237 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Peřina <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
