Skip to content

Commit

Permalink
improve: primary to secondary index edge case for dynamic mapper chan…
Browse files Browse the repository at this point in the history
…ges (#2246)



Signed-off-by: Attila Mészáros <csviri@gmail.com>
  • Loading branch information
csviri committed Feb 27, 2024
1 parent 37eb90b commit c47a551
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ 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. Like if a list of ResourceIDs mapped dynamically extended in the
// mapper between the onAddOrUpdate and onDelete is called.
if (secondaryResources != null) {
secondaryResources.remove(ResourceID.fromResource(resource));
if (secondaryResources.isEmpty()) {
index.remove(primaryResource);
}
}
});
}
Expand Down

0 comments on commit c47a551

Please sign in to comment.