Martin Sivák has uploaded a new change for review. Change subject: engine: Fix a possible NPE when the user removes stale policy unit ......................................................................
engine: Fix a possible NPE when the user removes stale policy unit When the external scheduler is in use and some plugin disappears, the plugin is still visible (in disabled form) in the Manage Policy Units dialog. If the user tries to remove it it has to work correctly and not raise NPE. Change-Id: I5fa617af3363ec1d71cf8f0a25af43be4b141067 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1065914 Signed-off-by: Martin Sivak <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java 1 file changed, 9 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/53/24953/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java index ff802cd..66f8815 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java @@ -849,11 +849,18 @@ /** * returns all cluster policies names containing the specific policy unit. * @param policyUnitId - * @return + * @return List of cluster policy names that use the referenced policyUnitId + * or null if the policy unit is not available. */ public List<String> getClusterPoliciesNamesByPolicyUnitId(Guid policyUnitId) { List<String> list = new ArrayList<String>(); - PolicyUnit policyUnit = policyUnits.get(policyUnitId).getPolicyUnit(); + final PolicyUnitImpl policyUnitImpl = policyUnits.get(policyUnitId); + if (policyUnitImpl == null) { + log.warnFormat("Trying to find usages of non-existing policy unit %s", policyUnitId.toString()); + return null; + } + + PolicyUnit policyUnit = policyUnitImpl.getPolicyUnit(); if (policyUnit != null) { for (ClusterPolicy clusterPolicy : policyMap.values()) { switch (policyUnit.getPolicyUnitType()) { -- To view, visit http://gerrit.ovirt.org/24953 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5fa617af3363ec1d71cf8f0a25af43be4b141067 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
