modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 16 +++------- modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 4 ++ 2 files changed, 9 insertions(+), 11 deletions(-)
New commits: commit 2e223b0da5b8643d38cc970482a513c8f8dd4ee8 Author: Jay Shaughnessy jshaughn@jshaughn.csb Date: Fri Feb 1 14:33:00 2013 -0500
Protect against NotNull assumptions
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 59a669e..7043c1f 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -2899,6 +2899,10 @@ public class InventoryManager extends AgentService implements ContainerService,
// add the newly fetched resources to the end of our master list for (Resource r : resourceBatch) { + // protect against childResources notNull assumptions downstream + if (null == r.getChildResources()) { + r.setChildResources(null); // this will actually initialize to an empty Set + } resourceMap.put(r.getId(), r); }
commit 03175821fa0cf8ad77d01691f72e71c8a920327c Author: Jay Shaughnessy jshaughn@jshaughn.csb Date: Fri Feb 1 14:31:53 2013 -0500
Add some null protection to addChildResource
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java index 5134451..be29fd6 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java @@ -55,9 +55,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient;
-import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import org.rhq.core.domain.alert.AlertDefinition; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PluginConfigurationUpdate; @@ -1125,10 +1122,7 @@ public class Resource implements Comparable<Resource>, Serializable { this.id = id; }
- public Resource( // - @NotNull String resourceKey, // - String name, // - @NotNull ResourceType type) { + public Resource(String resourceKey, String name, ResourceType type) { this(); this.resourceKey = resourceKey; this.name = name; @@ -1371,13 +1365,15 @@ public class Resource implements Comparable<Resource>, Serializable { this.location = location; }
- @NotNull public Set<Resource> getChildResources() { return this.childResources; }
public void addChildResource(Resource childResource) { childResource.setParentResource(this); + if (null == this.childResources) { + this.childResources = new HashSet<Resource>(1); + } this.childResources.add(childResource); }
@@ -1399,12 +1395,11 @@ public class Resource implements Comparable<Resource>, Serializable { } }
- @Nullable public Resource getParentResource() { return parentResource; }
- public void setParentResource(@Nullable Resource parentResource) { + public void setParentResource(Resource parentResource) { this.parentResource = parentResource; updateAncestryForResource(); } @@ -1559,7 +1554,6 @@ public class Resource implements Comparable<Resource>, Serializable { this.explicitGroups.remove(explicitGroup); }
- @NotNull public List<ResourceOperationHistory> getOperationHistories() { if (this.operationHistories == null) { this.operationHistories = new ArrayList<ResourceOperationHistory>();
rhq-commits@lists.fedorahosted.org