Skip to content

Commit 55a8723

Browse files
committed
improve: primary to secondary index edge case for dynamic mapper changes
Signed-off-by: Attila Mészáros <csviri@gmail.com>
1 parent 69711cf commit 55a8723

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ public synchronized void onDelete(R resource) {
3333
primaryResources.forEach(
3434
primaryResource -> {
3535
var secondaryResources = index.get(primaryResource);
36-
secondaryResources.remove(ResourceID.fromResource(resource));
37-
if (secondaryResources.isEmpty()) {
38-
index.remove(primaryResource);
36+
// this can be null in just very special cases, like when the secondaryToPrimaryMapper is
37+
// changing dynamically
38+
if (secondaryResources != null) {
39+
secondaryResources.remove(ResourceID.fromResource(resource));
40+
if (secondaryResources.isEmpty()) {
41+
index.remove(primaryResource);
42+
}
3943
}
4044
});
4145
}

0 commit comments

Comments
 (0)