Yair Zaslavsky has uploaded a new change for review. Change subject: core: Fix coverity report ......................................................................
core: Fix coverity report Fixed potential NPEs due to the fact that CommandBase.getBackendCommandObjectsHandler() may return null due to (unlikely) lookup problems. Change-Id: I556393be5e0955386d4f3056c55454ed3847b625 Signed-off-by: Yair Zaslavsky <yzasl...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java 1 file changed, 23 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/23980/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java index ceeaefe..23de0cd 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java @@ -151,7 +151,14 @@ protected VdcReturnValueBase executeChildCommand(Guid idInCommandsMap) { CommandBase<?> command = childCommandsMap.get(idInCommandsMap); - return getBackendCommandObjectsHandler().runAction(command, getExecutionContext()); + BackendCommandObjectsHandler backendCommandObjectsHandler = getBackendCommandObjectsHandler(); + if (backendCommandObjectsHandler != null) { + return backendCommandObjectsHandler.runAction(command, getExecutionContext()); + } + VdcReturnValueBase retValue = new VdcReturnValueBase(); + retValue.setSucceeded(false); + retValue.setFault(new VdcFault(new NullPointerException("Failed to create command object"), VdcBllErrors.ENGINE)); + return retValue; } @@ -198,10 +205,10 @@ } /** - * This method should be used only at {@link CommandBase} code for creating - * and execution {@link CommandBase} objects directly. - * This is the reason for the method being private and the JNDI name not introduced to - * the {@link BeanType} enum. + * This method should be used only at {@link CommandBase} code for creating and execution {@link CommandBase} + * objects directly. This is the reason for the method being private and the JNDI name not introduced to the + * {@link BeanType} enum. + * * @return proxy object to create the {@link CommandBase} objects and run them */ private BackendCommandObjectsHandler getBackendCommandObjectsHandler() { @@ -1271,12 +1278,17 @@ @Override public Void runInTransaction() { buildChildCommandInfos(); - for (Map.Entry<Guid, Pair<VdcActionType, VdcActionParametersBase>> entry : childCommandInfoMap.entrySet()) { - CommandBase<?> command = - getBackendCommandObjectsHandler().createAction(entry.getValue().getFirst(), - entry.getValue().getSecond()); - command.insertAsyncTaskPlaceHolders(); - childCommandsMap.put(entry.getKey(), command); + BackendCommandObjectsHandler backendCommandObjectsHandler = getBackendCommandObjectsHandler(); + if (backendCommandObjectsHandler != null) { + for (Map.Entry<Guid, Pair<VdcActionType, VdcActionParametersBase>> entry : childCommandInfoMap.entrySet()) { + CommandBase<?> command = + backendCommandObjectsHandler.createAction(entry.getValue().getFirst(), + entry.getValue().getSecond()); + if (command != null) { + command.insertAsyncTaskPlaceHolders(); + childCommandsMap.put(entry.getKey(), command); + } + } } return null; } -- To view, visit http://gerrit.ovirt.org/23980 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I556393be5e0955386d4f3056c55454ed3847b625 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yair Zaslavsky <yzasl...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches