CLOUDSTACK-4572: findHostsForMigration API does not return correct host list

Changes:
Expected behavior:
The api should return the list of suitable/unsuitable hosts
Added fix that creates a deep copy of the the variable allHosts and prevents faulty host list return.
This commit is contained in:
Saksham Srivastava 2013-08-30 12:30:41 -07:00 committed by Prachi Damle
parent e362f51f37
commit 6354604eed
1 changed files with 4 additions and 2 deletions

View File

@ -1161,8 +1161,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
null, null, null);
}
Pair<List<? extends Host>, Integer> otherHosts = new Pair<List <? extends Host>, Integer>(allHosts,
new Integer(allHosts.size()));
//'otherHosts' must use the current value of allHosts as allHosts may get modified later in the allocator
List<HostVO> allHostsCpy = new ArrayList<HostVO>(allHosts);
Pair<List<? extends Host>, Integer> otherHosts = new Pair<List <? extends Host>, Integer>(allHostsCpy,
new Integer(allHostsCpy.size()));
List<Host> suitableHosts = new ArrayList<Host>();
ExcludeList excludes = new ExcludeList();
excludes.addHost(srcHostId);