Author: adietish
Date: 2010-11-15 11:11:15 -0500 (Mon, 15 Nov 2010)
New Revision: 26564
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Log:
[JBIDE-7581] fixed NPE with uninitialized instances list
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-11-15
16:06:18 UTC (rev 26563)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-11-15
16:11:15 UTC (rev 26564)
@@ -235,16 +235,21 @@
}
public DeltaCloudImage[] notifyImageListListeners() {
- DeltaCloudImage[] images = cloneImages();
+ DeltaCloudImage[] images = cloneImagesArray();
notifyImageListListeners(images);
return images;
}
- private DeltaCloudImage[] cloneImages() {
+ private DeltaCloudImage[] cloneImagesArray() {
DeltaCloudImage[] imageArray = new DeltaCloudImage[images.size()];
return images.toArray(imageArray);
}
+ private DeltaCloudInstance[] cloneInstancesArray() {
+ DeltaCloudInstance[] instanceArray = new DeltaCloudInstance[instances.size()];
+ return instances.toArray(instanceArray);
+ }
+
public void notifyImageListListeners(DeltaCloudImage[] array) {
Object[] listeners = imageListeners.getListeners();
for (int i = 0; i < listeners.length; ++i)
@@ -485,7 +490,7 @@
if (images == null) {
return loadImages();
}
- return cloneImages();
+ return cloneImagesArray();
}
}
@@ -539,9 +544,9 @@
if (instance != null) {
DeltaCloudInstance newInstance = new DeltaCloudInstance(this, instance);
newInstance.setGivenName(name);
+ getCurrInstances(); // make sure instances are initialized
instances.add(newInstance);
- DeltaCloudInstance[] instanceArray = new DeltaCloudInstance[instances.size()];
- instanceArray = instances.toArray(instanceArray);
+ DeltaCloudInstance[] instanceArray = cloneInstancesArray();
notifyInstanceListListeners(instanceArray);
return newInstance;
}
Show replies by date