Avoid ConcurrentModificationException by using CopyOnWriteArrayList
Change-Id: I91b1f8b1ae8a9ec71166e037b4014536452c7f8c
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
index bd42125..731090d 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
@@ -19,7 +19,6 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.apache.felix.scr.annotations.Activate;
@@ -97,6 +96,7 @@
import java.util.ArrayList;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@@ -173,8 +173,8 @@
protected Multimap<DeviceId, VlanId> ignoredVlans = HashMultimap.create();
private InternalHostListener hostListener = new InternalHostListener();
- private List<DhcpServerInfo> defaultServerInfoList = Lists.newArrayList();
- private List<DhcpServerInfo> indirectServerInfoList = Lists.newArrayList();
+ private List<DhcpServerInfo> defaultServerInfoList = new CopyOnWriteArrayList<>();
+ private List<DhcpServerInfo> indirectServerInfoList = new CopyOnWriteArrayList<>();
private Dhcp4HandlerUtil dhcp4HandlerUtil = new Dhcp4HandlerUtil();
@Activate
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
index e38e6cd..0fed65a 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
@@ -111,6 +111,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.ArrayList;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@@ -195,8 +196,8 @@
private InternalHostListener hostListener = new InternalHostListener();
private Boolean dhcpFpmEnabled = false;
private Dhcp6HandlerUtil dhcp6HandlerUtil = new Dhcp6HandlerUtil();
- private List<DhcpServerInfo> defaultServerInfoList = Lists.newArrayList();
- private List<DhcpServerInfo> indirectServerInfoList = Lists.newArrayList();
+ private List<DhcpServerInfo> defaultServerInfoList = new CopyOnWriteArrayList<>();
+ private List<DhcpServerInfo> indirectServerInfoList = new CopyOnWriteArrayList<>();
private class IpAddressInfo {
Ip6Address ip6Address;
long prefTime;