Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/806#discussion_r39265110 --- Diff: vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java --- @@ -577,41 +590,48 @@ public ManagedObjectReference getDecendentMoRef(ManagedObjectReference root, Str return null; } - // Create PropertySpecs - PropertySpec pSpec = new PropertySpec(); - pSpec.setType(type); - pSpec.setAll(false); - pSpec.getPathSet().add("name"); - - ObjectSpec oSpec = new ObjectSpec(); - oSpec.setObj(root); - oSpec.setSkip(false); - oSpec.getSelectSet().addAll(constructCompleteTraversalSpec()); - - PropertyFilterSpec spec = new PropertyFilterSpec(); - spec.getPropSet().add(pSpec); - spec.getObjectSet().add(oSpec); - List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>(); - specArr.add(spec); - - List<ObjectContent> ocary = vimPort.retrieveProperties(getPropCol(), specArr); - - if (ocary == null || ocary.size() == 0) { - return null; - } + try { + // Create PropertySpecs + PropertySpec pSpec = new PropertySpec(); + pSpec.setType(type); + pSpec.setAll(false); + pSpec.getPathSet().add("name"); + + ObjectSpec oSpec = new ObjectSpec(); + oSpec.setObj(root); + oSpec.setSkip(false); + oSpec.getSelectSet().addAll(constructCompleteTraversalSpec()); + + PropertyFilterSpec spec = new PropertyFilterSpec(); + spec.getPropSet().add(pSpec); + spec.getObjectSet().add(oSpec); + List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>(); + specArr.add(spec); + + ManagedObjectReference propCollector = getPropCol(); + List<ObjectContent> ocary = vimPort.retrieveProperties(propCollector, specArr); + + if (ocary == null || ocary.size() == 0) { + return null; + } - // filter through retrieved objects to get the first match. - for (ObjectContent oc : ocary) { - ManagedObjectReference mor = oc.getObj(); - List<DynamicProperty> propary = oc.getPropSet(); - if (type == null || type.equals(mor.getType())) { - if (propary.size() > 0) { - String propval = (String)propary.get(0).getVal(); - if (propval != null && name.equalsIgnoreCase(propval)) - return mor; + // filter through retrieved objects to get the first match. + for (ObjectContent oc : ocary) { + ManagedObjectReference mor = oc.getObj(); + List<DynamicProperty> propary = oc.getPropSet(); + if (type == null || type.equals(mor.getType())) { + if (propary.size() > 0) { + String propval = (String)propary.get(0).getVal(); + if (propval != null && name.equalsIgnoreCase(propval)) + return mor; + } } } + } catch (Exception e) { --- End diff -- please catch specific exceptions, not just anything
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---