Skip to content

Commit

Permalink
improve: primary to secondary index edge case for dynamic mapper changes
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Mészáros <csviri@gmail.com>
  • Loading branch information
csviri committed Feb 21, 2024
1 parent 69711cf commit 55a8723
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ public synchronized void onDelete(R resource) {
primaryResources.forEach(
primaryResource -> {
var secondaryResources = index.get(primaryResource);
secondaryResources.remove(ResourceID.fromResource(resource));
if (secondaryResources.isEmpty()) {
index.remove(primaryResource);
// this can be null in just very special cases, like when the secondaryToPrimaryMapper is
// changing dynamically
if (secondaryResources != null) {
secondaryResources.remove(ResourceID.fromResource(resource));
if (secondaryResources.isEmpty()) {
index.remove(primaryResource);
}
}
});
}
Expand Down

0 comments on commit 55a8723

Please sign in to comment.