Avoid invalidating the cache if removing an entry doesn't exist

Closes #27852

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
Alexander Schwartz 2024-03-13 12:17:01 +01:00 committed by Alexander Schwartz
parent d679c13040
commit f168b8cce9

View file

@ -192,8 +192,10 @@ public class UserAdapter implements CachedUserModel {
@Override @Override
public void removeAttribute(String name) { public void removeAttribute(String name) {
getDelegateForUpdate(); if (getFirstAttribute(name) != null) {
updated.removeAttribute(name); getDelegateForUpdate();
updated.removeAttribute(name);
}
} }
@Override @Override
@ -229,8 +231,10 @@ public class UserAdapter implements CachedUserModel {
@Override @Override
public void removeRequiredAction(RequiredAction action) { public void removeRequiredAction(RequiredAction action) {
getDelegateForUpdate(); if (getRequiredActionsStream().anyMatch(s -> Objects.equals(s, action.name()))) {
updated.removeRequiredAction(action); getDelegateForUpdate();
updated.removeRequiredAction(action);
}
} }
@Override @Override
@ -241,8 +245,10 @@ public class UserAdapter implements CachedUserModel {
@Override @Override
public void removeRequiredAction(String action) { public void removeRequiredAction(String action) {
getDelegateForUpdate(); if (getRequiredActionsStream().anyMatch(s -> Objects.equals(s, action))) {
updated.removeRequiredAction(action); getDelegateForUpdate();
updated.removeRequiredAction(action);
}
} }
@Override @Override