Skip to content

Commit 2483370

Browse files
authored
Concurrent modification exception (#178)
* Fix concurrent modification exception iterating and modifying the _bucketsByExpiration map via the expiredBucketMap view since these are no longer concurrent maps. This is fine since the entire class now runs in an actor under a single thread of excecution model.
1 parent d3c3bc5 commit 2483370

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/com/arpnetworking/metrics/mad/PeriodWorker.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ private void processRecord(final Record record) {
182182
int closedBucketCount = 0;
183183

184184
// Phase 1: Collect expired buckets
185-
for (final ZonedDateTime key : expiredBucketMap.keySet()) {
186-
for (final Bucket bucket : _bucketsByExpiration.remove(key)) {
187-
expiredBuckets.add(bucket);
188-
}
185+
for (final Map.Entry<ZonedDateTime, List<Bucket>> entry : expiredBucketMap.entrySet()) {
186+
expiredBuckets.addAll(entry.getValue());
189187
}
188+
expiredBucketMap.clear();
190189

191190
// Phase 2: Close the expired buckets
192191
for (final Bucket bucket : expiredBuckets) {

0 commit comments

Comments
 (0)