Updated Branches: refs/heads/4.2-forward e362f51f3 -> 6354604ee
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. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6354604e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6354604e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6354604e Branch: refs/heads/4.2-forward Commit: 6354604eedff0c5f4ddef4940ce02df80adb656c Parents: e362f51 Author: Saksham Srivastava <saksham.srivast...@citrix.com> Authored: Fri Aug 30 12:30:41 2013 -0700 Committer: Prachi Damle <pra...@cloud.com> Committed: Fri Aug 30 12:31:25 2013 -0700 ---------------------------------------------------------------------- server/src/com/cloud/server/ManagementServerImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6354604e/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 3341c05..8437c99 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -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);