Madan Jampani

ONOS-2626: Make a immutable copy of multimap before iterating over it

Change-Id: I04cddc4fb9a007920783e44b62143d5d2c0553ba
...@@ -50,6 +50,7 @@ import org.onosproject.store.service.StorageService; ...@@ -50,6 +50,7 @@ import org.onosproject.store.service.StorageService;
50 import org.slf4j.Logger; 50 import org.slf4j.Logger;
51 51
52 import com.google.common.collect.HashMultimap; 52 import com.google.common.collect.HashMultimap;
53 +import com.google.common.collect.ImmutableMultimap;
53 import com.google.common.collect.ImmutableSet; 54 import com.google.common.collect.ImmutableSet;
54 import com.google.common.collect.Multimaps; 55 import com.google.common.collect.Multimaps;
55 import com.google.common.collect.SetMultimap; 56 import com.google.common.collect.SetMultimap;
...@@ -174,7 +175,8 @@ public class ECHostStore ...@@ -174,7 +175,8 @@ public class ECHostStore
174 175
175 @Override 176 @Override
176 public Set<Host> getConnectedHosts(DeviceId deviceId) { 177 public Set<Host> getConnectedHosts(DeviceId deviceId) {
177 - return locations.entries() 178 + return ImmutableMultimap.copyOf(locations)
179 + .entries()
178 .stream() 180 .stream()
179 .filter(entry -> entry.getKey().deviceId().equals(deviceId)) 181 .filter(entry -> entry.getKey().deviceId().equals(deviceId))
180 .map(entry -> entry.getValue()) 182 .map(entry -> entry.getValue())
......