Permalink
Browse files

fixing bug that returns an array with null entries

  • Loading branch information...
buzztroll committed Dec 1, 2011
1 parent 15d9fe2 commit 210fc650ec1f5636ba734ed2852a4e5a8d4d644a
@@ -394,24 +394,24 @@ else if(dnAlias.size() > 1)
*/
private VM[] getVMByHost(String hostname) {
try {
- VM[] vms;
+ ArrayList<VM> vms;
VM[] all = manager.getGlobalAll();
int cnt = 0;
- vms = new VM[all.length];
+ vms = new ArrayList<VM>(all.length);
for(int i = 0; i < all.length; i++) {
String id = all[i].getID();
String host = workspaceHome.find(id).getVM().getNode();
if(host.equals(hostname))
- vms[cnt++] = all[i];
+ vms.add(all[i]);
}
if(cnt == 0) {
errorMsg = "No vms with hostname " + hostname + " found";
return null;
}
else
- return vms;
+ return vms.toArray(new VM[0]);
}
catch (DoesNotExistException e) {
errorMsg = "Hostname " + hostname + " not found";

0 comments on commit 210fc65

Please sign in to comment.