From 6354604eedff0c5f4ddef4940ce02df80adb656c Mon Sep 17 00:00:00 2001 From: Saksham Srivastava Date: Fri, 30 Aug 2013 12:30:41 -0700 Subject: [PATCH] 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. --- server/src/com/cloud/server/ManagementServerImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 3341c05da97..8437c9924f3 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, Integer> otherHosts = new Pair, Integer>(allHosts, - new Integer(allHosts.size())); + //'otherHosts' must use the current value of allHosts as allHosts may get modified later in the allocator + List allHostsCpy = new ArrayList(allHosts); + Pair, Integer> otherHosts = new Pair, Integer>(allHostsCpy, + new Integer(allHostsCpy.size())); List suitableHosts = new ArrayList(); ExcludeList excludes = new ExcludeList(); excludes.addHost(srcHostId);