Skip to content

Commit 31628b5

Browse files
authored
fix: concurrent modification exception accessing secondary resources (#1243)
1 parent a3c2dd7 commit 31628b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/PrimaryToSecondaryIndex.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.javaoperatorsdk.operator.processing.event.source.informer;
22

33
import java.util.*;
4+
import java.util.concurrent.ConcurrentHashMap;
45

56
import io.fabric8.kubernetes.api.model.HasMetadata;
67
import io.javaoperatorsdk.operator.processing.event.ResourceID;
@@ -19,7 +20,8 @@ public synchronized void onAddOrUpdate(R resource) {
1920
Set<ResourceID> primaryResources = secondaryToPrimaryMapper.toPrimaryResourceIDs(resource);
2021
primaryResources.forEach(
2122
primaryResource -> {
22-
var resourceSet = index.computeIfAbsent(primaryResource, pr -> new HashSet<>());
23+
var resourceSet =
24+
index.computeIfAbsent(primaryResource, pr -> ConcurrentHashMap.newKeySet());
2325
resourceSet.add(ResourceID.fromResource(resource));
2426
});
2527
}

0 commit comments

Comments
 (0)