Fix ConcurrentModificationException

Change-Id: Ie4c3a56312156ded1cbc2fd8a0e4da822ff57205
This commit is contained in:
Charles Chan 2018-06-18 14:42:17 -07:00 committed by Charles Chan
parent 6a7d3677f2
commit f2f8ef043b

View File

@ -463,9 +463,12 @@ public class DeviceConfiguration implements DeviceProperties {
*/
public Set<IpPrefix> getSubnets(DeviceId deviceId) {
SegmentRouterInfo srinfo = deviceConfigMap.get(deviceId);
if (srinfo != null) {
if (srinfo != null && srinfo.subnets != null) {
// Note: ImmutableSet.Builder.addAll calls the iterator of parameter internally,
// which is not protected by SynchronizedCollection mutex.
ImmutableSet.Builder<IpPrefix> builder = ImmutableSet.builder();
return builder.addAll(srinfo.subnets.values()).build();
srinfo.subnets.forEach((k, v) -> builder.add(v));
return builder.build();
}
return null;
}