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