Madan Jampani
Committed by Gerrit Code Review

Fix logic that checks if the request tracking ConsistentMap was updated

Change-Id: I0f7c6e8b9ee89ab8209e36b6933345375dabf477
...@@ -213,6 +213,9 @@ public class DistributedPacketStore ...@@ -213,6 +213,9 @@ public class DistributedPacketStore
213 private AtomicBoolean addInternal(PacketRequest request) { 213 private AtomicBoolean addInternal(PacketRequest request) {
214 AtomicBoolean firstRequest = new AtomicBoolean(false); 214 AtomicBoolean firstRequest = new AtomicBoolean(false);
215 requests.compute(request.selector(), (s, existingRequests) -> { 215 requests.compute(request.selector(), (s, existingRequests) -> {
216 + // Reset to false just in case this is a retry due to
217 + // ConcurrentModificationException
218 + firstRequest.set(false);
216 if (existingRequests == null) { 219 if (existingRequests == null) {
217 firstRequest.set(true); 220 firstRequest.set(true);
218 return ImmutableSet.of(request); 221 return ImmutableSet.of(request);
...@@ -239,6 +242,9 @@ public class DistributedPacketStore ...@@ -239,6 +242,9 @@ public class DistributedPacketStore
239 private AtomicBoolean removeInternal(PacketRequest request) { 242 private AtomicBoolean removeInternal(PacketRequest request) {
240 AtomicBoolean removedLast = new AtomicBoolean(false); 243 AtomicBoolean removedLast = new AtomicBoolean(false);
241 requests.computeIfPresent(request.selector(), (s, existingRequests) -> { 244 requests.computeIfPresent(request.selector(), (s, existingRequests) -> {
245 + // Reset to false just in case this is a retry due to
246 + // ConcurrentModificationException
247 + removedLast.set(false);
242 if (existingRequests.contains(request)) { 248 if (existingRequests.contains(request)) {
243 Set<PacketRequest> newRequests = Sets.newHashSet(existingRequests); 249 Set<PacketRequest> newRequests = Sets.newHashSet(existingRequests);
244 newRequests.remove(request); 250 newRequests.remove(request);
......