Better to print an error message than to die with a npe. Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/33433623 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/33433623 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/33433623
Branch: refs/heads/regions Commit: 334336232850e3bfc66d302d19a0aa8ade0c7b83 Parents: 9ebe832 Author: Hugo Trippaers <[email protected]> Authored: Tue Oct 2 07:35:10 2012 -0700 Committer: Hugo Trippaers <[email protected]> Committed: Tue Oct 2 07:35:10 2012 -0700 ---------------------------------------------------------------------- .../dao/CloudStackConfigurationDaoImpl.java | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/33433623/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java b/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java index c49f612..6333042 100644 --- a/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java +++ b/awsapi/src/com/cloud/bridge/persist/dao/CloudStackConfigurationDaoImpl.java @@ -52,7 +52,12 @@ public class CloudStackConfigurationDaoImpl extends GenericDaoBase<CloudStackCon txn.start(); SearchCriteria<CloudStackConfigurationVO> sc = NameSearch.create(); sc.setParameters("name", name); - return findOneBy(sc).getValue(); + CloudStackConfigurationVO configItem = findOneBy(sc); + if (configItem == null) { + s_logger.warn("No configuration item found with name " + name); + return null; + } + return configItem.getValue(); }finally { }
